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
15 changes: 15 additions & 0 deletions climbing-stairs/jaekwang97.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
  • 설명: climbStairs 문제를 피보나치 수열 형태로 DP 배열을 이용해 문제를 해결합니다. 하위 문제의 해를 이용해 상위 문제의 해를 계산하는 전형적인 DP 패턴입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 동적계획법으로 k번째 계단 수를 이전 두 계단의 합으로 계산합니다.

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

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int climbStairs(int n) {
int[] dp = new int[n + 1];
if (n <= 3) return n;
dp[1] = 1;
dp[2] = 2;
dp[3] = 3;

for (int i = 4; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}

return dp[n];
}
}
Comment on lines +1 to +15

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.

DP 정석적인 풀이대로 잘 하신것 같습니다!
다만

  • 몇 번째 항이 초기항이고, 이후 어느 항부터 점화식이 적용되는지 다시 한번 살펴보시는 것도 좋을것 같습니다.
  • 지금 이 풀이에서는 n 이하의 모든 값을 다 저장하고 있는데, 굳이 다 저장할 필요가 있을까요? 저장하지 않는 풀이도 한번 생각해보시는거 어떨까요?

26 changes: 26 additions & 0 deletions product-of-array-except-self/jaekwang97.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, Dynamic Programming, Hash Map / Hash Set
  • 설명: 배열의 왼쪽/오른쪽 누적 곱을 미리 계산해 각 원소를 제외한 곱을 구하는 방식으로, 중간에 임시 배열을 두고 부분해를 합성하는 DP-like 전처리 패턴입니다. 두 포인터로 순회를 이용한 최적화는 아니지만, 부분구간의 누적 정보를 이용한다는 점에서 DP 계열에 속합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 왼쪽/오른쪽 누적곱 배열을 만들어 각 위치의 결과를 곱해 구합니다.

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

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

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

class Solution {
public int[] productExceptSelf(int[] nums) {
int n = nums.length;
int[] right = new int[n + 1];
int[] left = new int[n + 1];

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

left[n] = 1;
for (int i = n - 1; i >= 0; i--) {
left[i] = left[i + 1] * nums[i];
}

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

return answer;
}
}
Comment on lines +1 to +26

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.

저는 처음에 잘못된 풀이(나눗셈을 사용한)로 풀었었는데,
@JAEKWANG97 님 풀이를 보고 제가 틀렸다는걸 알게됐어요.

21 changes: 21 additions & 0 deletions valid-anagram/jaekwang97.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
  • 설명: 두 문자열의 문자 등장 횟수를 비교하기 위해 배열로 카운트를 세고 차이를 검사하는 방식으로 해시 맵/세트의 역할을 수행하는 패턴에 속합니다. 또한 문자 인덱스 계산은 간접적으로 비트 연산과 유사한 상수 시간 접근을 활용합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n + m)
Space O(1)

피드백: 고정 크기의 카운트 배열로 각 문자의 차이를 반영합니다.

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

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

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

class Solution {
public boolean isAnagram(String s, String t) {
int[] count = new int[26];

for (char c : s.toCharArray()) {
count[c - 'a']++;
}

for (char c : t.toCharArray()) {
count[c - 'a']--;
}

for (int n : count) {
if (n != 0) return false;
}

return true;
}
}
Loading