Skip to content
Merged
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
14 changes: 14 additions & 0 deletions coin-change/j2h30728.ts

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
  • 설명: 코인 교환 문제를 금액별 최솟값으로 나타내는 부분 문제의 최적해를 쌓아가는 DP 방식으로 풀이합니다. 이중 루프는 금액마다 가능한 동전을 고려해 최솟값을 갱신합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(amount * k)
Space O(amount)

피드백: 외부 반복으로 모든 금액에 대해 각 동전을 활용한 최소 개수를 갱신하는 표를 사용한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function coinChange(coins: number[], amount: number): number {
const dp = new Array(amount + 1).fill(amount + 1);
dp[0] = 0;

for (let i = 1; i <= amount; i++) {
for (const coin of coins) {
if (i - coin >= 0) {
dp[i] = Math.min(dp[i], 1 + dp[i - coin]);
}
}
}

return dp[amount] > amount ? -1 : dp[amount];
Comment on lines +2 to +13

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.

amount + 1, > amount 이 연관된 로직인데 드러나지 않아서 amount + 1 을 변수로 선언해서 사용하시면 좋을 거 같아요.

};
12 changes: 12 additions & 0 deletions find-minimum-in-rotated-sorted-array/j2h30728.ts

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search, Two Pointers
  • 설명: 정렬된 배열이 회전되었을 때 최소 원소를 찾기 위해 이분탐색으로 구간을 반으로 좁혀 가는 패턴이며, 좌우 포인터를 사용하여 탐색 범위를 조절합니다.

📊 시간/공간 복잡도 분석

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

피드백: 배열의 마지막 값을 기준으로 피봇 위치를 이분으로 좁혀 간다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function findMin(nums: number[]): number {
const n = nums.length - 1;

@parkhojeong parkhojeong Jul 19, 2026

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.

변수 명으로 n을 사용하신 이유가 있을까요?

let last = nums[n];
let left = 0, right = n;

while(left < right){
const mid = (left + right) >> 1;
if(nums[mid] > last) left = mid + 1;
else right = mid;
Comment on lines +3 to +9

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.

이진탐색인데 last가 고정되어 있네요. 잘 이해가 안되서 그런데 이 부분 설명해주실 수 있을까요?

}
return nums[left];
};
20 changes: 20 additions & 0 deletions maximum-depth-of-binary-tree/j2h30728.ts

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search, Binary Search
  • 설명: 이 코드는 재귀를 이용해 트리의 좌우 하위 문제를 먼저 탐색한 뒤 최대 깊이를 합산하는 방식으로 동작한다. 트리 구조를 순차적으로 방문하는 DFS 패턴의 대표 예시이다.

📊 시간/공간 복잡도 분석

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

피드백: 트리의 모든 노드를 한 번씩 방문하며 최대 깊이를 계산한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Definition for a binary tree node.
* class TreeNode {
* val: number
* left: TreeNode | null
* right: TreeNode | null
* constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
* }
* }
*/

function maxDepth(root: TreeNode | null): number {
if(!root) return 0;
const maxLeft = maxDepth(root.left);
const maxRight = maxDepth(root.right);
return Math.max(maxLeft, maxRight) + 1;
};
29 changes: 29 additions & 0 deletions merge-two-sorted-lists/j2h30728.ts

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, Merge
  • 설명: 리스트를 두 포인터(list1, list2)로 순회하며 작은 값을 차례대로 연결하는 방식으로 해결하는 패턴입니다. 남은 부분도 한 번의 연결으로 처리하므로 두 포인터의 이동과 연결이 핵심입니다.

📊 시간/공간 복잡도 분석

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

피드백: 두 리스트의 노드를 직접 연결해서 합친 뒤 남은 부분을 붙인다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Definition for singly-linked list.
* class ListNode {
* val: number
* next: ListNode | null
* constructor(val?: number, next?: ListNode | null) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
* }
*/

function mergeTwoLists(list1: ListNode | null, list2: ListNode | null): ListNode | null {
const root = new ListNode();
let tail = root;

while(list1 !== null && list2 !== null){
if(list1.val <= list2.val){
tail.next = list1;
list1 = list1.next;
}else{
tail.next = list2;
list2 = list2.next;
}
tail = tail.next;
}
tail.next = list1 !== null ? list1 : list2;
return root.next;
};
Loading