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
13 changes: 13 additions & 0 deletions climbing-stairs/jthw1005.js

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, Hash Map / Hash Set
  • 설명: 클라이밍 문제는 중복되는 부분 문제를 DP로 해결하며, 메모이제이션으로 결과를 저장해 재계산을 방지합니다. 해시 맵을 이용해 이미 계산된 값을 저장하는 방식도 보입니다.

📊 시간/공간 복잡도 분석

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

피드백: 상향식 재귀 + 메모이제이션으로 중복 계산을 피함으로써 전체 시간 복잡도는 선형이 된다. 공간은 memo 저장과 재귀 호출 스택의 합으로 선형이다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function climbStairs(n) {
const memo = {};

function dp(k) {
if (k === 1) return 1;
if (k === 2) return 2;
if (memo[k]) return memo[k];
memo[k] = dp(k - 1) + dp(k - 2);
return memo[k];
}

return dp(n);
}
14 changes: 14 additions & 0 deletions valid-anagram/jthw1005.js

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)

피드백: 모든 알파벳 소문자에 대해 차이를 누적/감소시키고, 최종적으로 0 여부를 확인한다. 입력 길이에 선형 시간, 알파벳 고정 크기 배열로 상수 공간을 사용한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const isAnagram = (s, t) => {
const data = new Array(26).fill(0);
const a_ascii = 'a'.charCodeAt();

for (const char of s) {
data[char.charCodeAt() - a_ascii]++;
}

for (const char of t) {
data[char.charCodeAt() - a_ascii]--;
}

return !data.some((el) => el !== 0);
};
Loading