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
26 changes: 26 additions & 0 deletions coin-change/seueooo.js

@parkhojeong parkhojeong Jul 24, 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.

요건 돌려보면 runtime이 5% 정도 나오는데 최적화 시도해보시면 좋을 거 같습니다.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: BFS
  • 설명: 이 코드는 각 합계를 노드로 보고 동전 조합의 최소 동전 개수를 찾기 위해 너비 우선 탐색(BFS)을 사용합니다. 큐에 상태를 순차적으로 확장하며 목표 합계에 도달하면 최단 경로의 동전 개수를 반환합니다.

📊 시간/공간 복잡도 분석

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

피드백: 수행 시 각 합을 한 번만 처리하도록 하여 최단 경로를 찾는다. 방문 중복 제거를 위해 Set를 사용한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* bfs
* 시간 복잡도: O(amount * n)
* 공간 복잡도: O(amount)
* @param {number[]} coins
* @param {number} amount
* @return {number}
*/
var coinChange = function (coins, amount) {
let q = [];
let visited = new Set();
q.push([0, 0]);
while (q.length) {
const [sum, count] = q.shift();
if (sum === amount) return count;
if (visited.has(sum)) continue;
visited.add(sum);
for (let i = 0; i < coins.length; i++) {
const nextSum = sum + coins[i];
if (nextSum <= amount) {
q.push([nextSum, count + 1]);
}
}
}
return -1;
};
22 changes: 22 additions & 0 deletions find-minimum-in-rotated-sorted-array/seueooo.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search
  • 설명: 배열이 회전된 정렬 배열에서 이분 탐색으로 최소값의 인덱스를 찾는 전형적인 패턴으로, 중간값과 경계 비교를 통해 탐색 범위를 절반으로 줄인다.

📊 시간/공간 복잡도 분석

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

피드백: 정렬된 부분과 회전된 부분의 경계로 좁혀가며 최소값 위치를 찾는다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
이분 탐색
시간 복잡도 : O(log n)
공간 복잡도 : O(1)
* @param {number[]} nums
* @return {number}
*/
var findMin = function (nums) {
let left = 0;
let right = nums.length - 1;

while (left < right) {
let mid = Math.floor((left + right) / 2);
if (nums[mid] > nums[right]) {
left = mid + 1;
} else {
right = mid;
}
}

return nums[left];
};
17 changes: 17 additions & 0 deletions maximum-depth-of-binary-tree/seueooo.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search, Recursive Programming
  • 설명: 재귀적으로 트리를 탐색하며 왼쪽/오른쪽 자식을 각각 깊이를 구한 뒤 최대값에 1을 더해 트리의 최대 깊이를 구하는 전형적인 DFS 형태의 재귀 풀이.

📊 시간/공간 복잡도 분석

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

피드백: 트리의 모든 노드를 한 번씩 방문하고 각 재귀 호출이 깊이만큼 스택을 사용한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
재귀
* Definition for a binary tree node.
* function TreeNode(val, left, right) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
* }
*/
/**
* @param {TreeNode} root
* @return {number}
*/
var maxDepth = function (root) {
if (!root) return 0;
return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
};
31 changes: 31 additions & 0 deletions merge-two-sorted-lists/seueooo.js

@parkhojeong parkhojeong Jul 24, 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.

재귀로 풀어주셨네요. 재귀 아닌 방식으로 풀어보셔도 재밌으실 거 같습니다.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Divide and Conquer, Recursive (implicit)
  • 설명: 두 정렬된 연결 리스트를 재귀적으로 합치는 방식으로 문제를 분할하고, 각 부분 문제의 해를 결합하여 전체 해를 구한다. 재귀 호출 스택으로 공간이 사용되며, 기본 사례는 비어있는 리스트 처리이다.

📊 시간/공간 복잡도 분석

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

피드백: 작은 노드를 머리로 두고 남은 부분을 재귀적으로 연결한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 풀이
* 더 작은 노드를 머리로 두고, 그 next에 나머지를 병합한 결과를 연결.
* 최종적으로 머리를 반환
*
* 시간복잡도 - O(n + m) : n, m은 각각 list1, list2의 길이
* 공간복잡도 - O(n + m) : 재귀 호출 스택
*
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} list1
* @param {ListNode} list2
* @return {ListNode}
*/
var mergeTwoLists = function (list1, list2) {
if (!list1) return list2;
if (!list2) return list1;

if (list1.val <= list2.val) {
list1.next = mergeTwoLists(list1.next, list2);
return list1;
} else {
list2.next = mergeTwoLists(list1, list2.next);
return list2;
}
};
56 changes: 56 additions & 0 deletions word-search/seueooo.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.

더 최적화 한다면 어떤 부분이 있을지 한 번 고민해보셔도 좋을 거 같습니다.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Backtracking, Depth-First Search
  • 설명: 글자 하나씩 탐색하면서 방향으로 가능한 경로를 시도하고 실패 시 되돌려 다른 경로를 시도하는 백트래킹 방식과, 재귀로 깊이 우선 탐색을 같이 사용합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(rows * cols * 4^L)
Space O(rows * cols)

피드백: 백트래킹으로 가능한 경로를 탐색하고, 방문 여부를 원상태로 돌려 다른 경로를 탐색한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
현재 경로를 하나 선택해서 끝까지 진행하고, 실패하면 방문 표시를 되돌려 다른 경로를 시도
bfs, 백트래킹
* @param {character[][]} board
* @param {string} word
* @return {boolean}
*/
var exist = function (board, word) {
const rows = board.length;
const cols = board[0].length;

const dx = [-1, 1, 0, 0];
const dy = [0, 0, -1, 1];

function dfs(x, y, index) {
if (board[y][x] !== word[index]) {
return false;
}

if (index === word.length - 1) {
return true;
}

// 방문 처리
const original = board[y][x];
board[y][x] = "#";

for (let i = 0; i < 4; i++) {
const nx = x + dx[i];
const ny = y + dy[i];

if (
nx >= 0 &&
nx < cols &&
ny >= 0 &&
ny < rows &&
board[ny][nx] !== "#"
) {
if (dfs(nx, ny, index + 1)) {
board[y][x] = original;
return true;
}
}
}

board[y][x] = original;
return false;
}

for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (dfs(j, i, 0)) return true;
}
}
return false;
};
Loading