Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions climbing-stairs/JeonJe.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming, Memoization
  • 설명: 피보나치 수열 형태의 문제로 부분해를 저장하는 DFS 기반의 동적계획법(메모이제이션) 패턴입니다. 중복 계산을 피하기 위해 미리 계산된 값을 memo 배열에 저장합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(n) O(n)

피드백: 재귀적 탐색 대신 배열을 이용한 탑다운 형태의 메모이제이션으로 중복 계산을 제거합니다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.*;

// TC: O(n)
// SC: O(n)
class Solution {
static int[] memo = new int[46];


public int climbStairs(int n) {

if (n == 1) return 1;
if (n == 2) return 2;
memo[1] = 1;
memo[2] = 2;

dfs(n);
return memo[n];
}

private int dfs(int num) {

//이미 계산한적이 있으면
if (memo[num] != 0) {
return memo[num];
}

memo[num] = dfs(num - 1) + dfs(num - 2);
return memo[num];

}
}
22 changes: 22 additions & 0 deletions product-of-array-except-self/JeonJe.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Greedy, Hash Map / Hash Set
  • 설명: 문제는 각 위치의 배열 원소를 곱으로 나누지 않고 좌측 곱과 우측 곱을 누적해 결과를 구하는 방식으로, 두 방향에서 누적 곱을 사용하는 패턴(일명 Two Pointers 계열의 좌우 누적 곱)과 그 과정에서 추가 메모리 없이 O(1) 추가 공간을 활용하는 아이디어가 핵심입니다. 코드가 명시적으로 두 포인터를 서로 다른 방향으로 진행하며 결과를 구성합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(1) O(1)

피드백: 하나의 배열로 왼쪽 누적곱과 오른쪽 누적곱을 결합해 불필요한 곱셈 제거.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.*;

// TC: O(n)
// SC: O(1)
class Solution {
public int[] productExceptSelf(int[] nums) {
int n = nums.length;

int[] answer = new int[n];
answer[0] = 1;
for (int i = 1; i < n; i++) {
answer[i] = answer[i - 1] * nums[i - 1];
}

int right = 1;
for (int i = n - 2; i >= 0; i--) {
right = right * nums[i + 1];
answer[i] = answer[i] * right;
}
return answer;
}
}
21 changes: 21 additions & 0 deletions valid-anagram/JeonJe.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Bit Manipulation, Dynamic Programming, Greedy, Divide and Conquer, Two Pointers, Sliding Window, Fast & Slow Pointers, BFS, DFS, Backtracking, Dynamic Programming, Union Find, Trie, Monotonic Stack, Heap / Priority Queue
  • 설명: 두 문자열의 문자 카운트를 비교해 아나그램 여부를 판단하는 방식으로, 고정 크기 배열을 이용한 개수 비교는 해시 맵/세트의 아이디어를 단순화한 형태이며, 알파벳 각 문자 빈도 수를 비교하는 패턴이다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(1) O(1)

피드백: 길이가 같은 경우에 한 방향으로 빈도 수를 비교해 결과를 도출합니다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.util.*;

// TC: O(n)
// SC: O(1)
class Solution {
public boolean isAnagram(String s, String t) {
if (s.length() != t.length()) return false;

int[] countS = new int[26];
int[] countT = new int[26];
for (int i = 0; i < s.length(); i++) {
countS[s.charAt(i) - 'a']++;
countT[t.charAt(i) - 'a']++;
}

for (int i = 0; i < 26; i++) {
if (countS[i] != countT[i]) return false;
}
return true;
}
}
Loading