Skip to content

[WEEK01] 최준호#1

Merged
raejun92 merged 7 commits intomainfrom
raejun
Feb 19, 2026
Merged

[WEEK01] 최준호#1
raejun92 merged 7 commits intomainfrom
raejun

Conversation

@raejun92
Copy link
Copy Markdown
Collaborator

@raejun92 raejun92 commented Feb 11, 2026

이렇게 풀었어요

1. TwoSum

  • 문제를 풀었어요.
  • 풀이 시간 : 18분

1) 복잡도 계산

시간 복잡도: O(n log n) (정렬)
공간 복잡도: O(n)


2) 접근 아이디어

배열을 [값, 원본인덱스] 형태로 변환한 뒤 값 기준으로 정렬하고, 투 포인터로 양 끝에서 합을 비교하여 target을 찾습니다.


3) 회고

정렬 후 원본 인덱스를 보존하는 점이 핵심이었습니다. 투 포인터로 효율적으로 해결할 수 있었습니다.


2. Valid Parentheses

  • 문제를 풀었어요.
  • 풀이 시간 : 13분

1) 복잡도 계산

시간 복잡도: O(n)
공간 복잡도: O(n)


2) 접근 아이디어

스택을 사용하여 여는 괄호는 푸시하고, 닫는 괄호가 나오면 스택 탑과 비교하여 짝이 맞지 않으면 false를 반환합니다. 최종적으로 스택이 비어있으면 유효합니다.


3) 회고

스택을 활용한 전형적인 풀이로 직관적이며 효율적입니다.


3. Merge Two Sorted Lists

  • 문제를 풀었어요.
  • 풀이 시간 : -

1) 복잡도 계산

시간 복잡도: O(n + m)
공간 복잡도: O(1)


2) 접근 아이디어

두 리스트를 포인터로 순회하며 작은 값 쪽 노드를 이어붙이는 방식(더미 노드 사용 권장).


3) 회고

현재 구현에서 더미 노드 초기화 및 다음 노드 연결 로직에 문제가 있어 작동하지 않습니다. 더미 노드 패턴으로 재구현할 예정입니다.


4. Best Time to Buy and Sell Stock

  • 문제를 풀었어요.
  • 풀이 시간 : -

1) 복잡도 계산

현재 코드: O(n^2)
개선 목표: O(n)


2) 접근 아이디어

한 번의 순회로 현재까지의 최소값을 추적하고, 각 시점에서의 최대 이익을 갱신하는 방식으로 O(n)으로 개선할 수 있습니다.


3) 회고

현재는 브루트포스 요소가 있어 비효율적입니다. 다음 PR에서 O(n) 풀이로 개선하겠습니다.


doitchuu
doitchuu previously approved these changes Feb 13, 2026
Copy link
Copy Markdown
Member

@doitchuu doitchuu left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍 좋은 풀이가 많네요
PR 템플릿이랑 파일명만 수정 부탁드려요

}

return value;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

파일명은 BestTimeToBuyAndSellStock.js 등 카멜 케이스로 작성 부탁드립니다!

Comment thread raejun/TwoSum.js
return [newNums[start][1], newNums[end][1]];
}
}
}; No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이중 for문으로 해결하는 방식만 생각했었는데, 포인터를 시작점과 끝점을 두고 한번에 구현하는 방식이 더 좋네요 👍

Comment thread raejun/TwoSum.js
}

return stack.length === 0;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

깔끔하네요 풀이가 💯

Comment thread raejun/TwoSum.js
* @return {number[]}
*/
var twoSum = function(nums, target) {
const newNums = nums.map((v, i) => [v, i]).sort((a, b) => a[0] - b[0]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

저는 알고리즘 할 때 저렇게 자바스크립트만의 고차함수(?)를 잘 활용 못하겠던데 잘 쓰시네요 허허
그리고 투 포인터라니 그걸 여기서 떠올리셨다는 점 ... 존경합니다

Comment on lines +13 to +15
if (s[i] === ')' && top === '(') continue;
if (s[i] === ']' && top === '[') continue;
if (s[i] === '}' && top === '{') continue;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

continue로 흐름제어한거 좋은 것 같아요


for (let i = 0; i < prices.length; i++) {
const min = prices[i];
const max = Math.max(...prices.slice(i + 1));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

엣지케이스를 하나 찾아봤어요, prices = [1] 처럼 길이가 1이면 Math.max(...prices.slice(0+1))이 되어 값이 -Infinity가 출력될 수 있을 것 같아요!

sik9252
sik9252 previously approved these changes Feb 13, 2026
@raejun92 raejun92 dismissed stale reviews from sik9252 and doitchuu via 58a477d February 13, 2026 14:34
@raejun92 raejun92 changed the title Revert raejun/TwoSum.js to previous version [WEEK01-1] 최준호 Feb 13, 2026
@raejun92 raejun92 changed the title [WEEK01-1] 최준호 [WEEK01] 최준호 Feb 13, 2026
@raejun92 raejun92 requested review from doitchuu and sik9252 February 15, 2026 07:19
Comment thread raejun/TwoSum.js
@raejun92 raejun92 merged commit 121a835 into main Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants