Skip to content

[hyejj19] WEEK 01 solutions#2368

Merged
hyejj19 merged 7 commits intoDaleStudy:mainfrom
hyejj19:main
Mar 7, 2026
Merged

[hyejj19] WEEK 01 solutions#2368
hyejj19 merged 7 commits intoDaleStudy:mainfrom
hyejj19:main

Conversation

@hyejj19
Copy link
Contributor

@hyejj19 hyejj19 commented Mar 3, 2026

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@hyejj19 hyejj19 self-assigned this Mar 3, 2026
Copilot AI review requested due to automatic review settings March 3, 2026 05:16
@github-actions github-actions bot added the ts label Mar 3, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the author’s TypeScript solution for LeetCode #217 (Contains Duplicate) to the repository’s per-problem solution set.

Changes:

  • Added containsDuplicate implementation using a Set size comparison (O(n) time / O(n) space).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Cyjin-jani Cyjin-jani self-requested a review March 3, 2026 06:45
Copy link
Contributor

@Cyjin-jani Cyjin-jani left a comment

Choose a reason for hiding this comment

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

문제 풀이 고생 많으셨습니다!
남은 문제 & 다음주도 화이팅입니다💪💪

Comment on lines +1 to +2
function containsDuplicate(nums: number[]): boolean {
return new Set(nums).size !== nums.length;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍👍👍

const table = new Map();

for (let i = 0; i < nums.length; i++) {
const complement = target - nums[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

유의미한 변수명을 사용해주셨네요..!👍👍👍
(사실 영알못이라 뜻을 잘 몰라서 찾아봤었습니다..😅)

Comment on lines +7 to +9
if (table.has(complement)) {
return [table.get(complement)!, i];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Map의 get이 값 아니면 undefined를 반환해서 !를 붙여주신 것 같네요..! 👍👍

타입단언 없이도 할 수 있는 방법을 조금 고민해보았는데, 다음과 같이 작성해 볼 수도 있을 것 같습니다..!

Suggested change
if (table.has(complement)) {
return [table.get(complement)!, i];
}
const complementValue = table.get(complement);
if (complementValue !== undefined) {
return [complementValue, i];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗..! 그렇네요 다음번에는 if 조건문으로 확인하도록 하겠습니다!

Comment on lines +24 to +27
/* 개선점?
* Map 과 sort 이외의 방식이 없을까?
* Map 의 장점은 get 할 때 O(1) 인건데, sort 를 하면서 시간복잡도가 증가함.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

저랑 접근 방식이 다소 비슷해서 놀랐습니다 ㅎㅎ 저도 처음에 sort를 썼다가 시간복잡도가 증가해서 어떻게든 O(n)으로 줄이기 위해 2번째 시도와 거의 동일한 방법으로 해결했었습니다..!

for (let i = bucket.length - 1; i >= 0; i--) {
// 값이 비어있지 않다면, 해당 인덱스 순서만큼 카운팅된 숫자 밸류를 의미
if (bucket[i].length > 0) {
answer.push(...bucket[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

처음에 스프레드 연산자로 전부 push하면 갯수가 k보다 커질 수도 있으니 엣지 케이스가 발생하는 게 아닌가 하는 우려(?)가 있었는데요, 다음 제약조건 때문에 문제가 없는 것 같네요! 👍👍👍

(제약 조건을 좀 더 꼼꼼히 봐야겠다고 반성했습니다 😅)

It is guaranteed that the answer is unique.

@hyejj19 hyejj19 merged commit 24afbc9 into DaleStudy:main Mar 7, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Solving to Completed in 리트코드 스터디 7기 Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

3 participants