Skip to content

[Yg-cho] WEEK 01 Solutions #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

[Yg-cho] WEEK 01 Solutions #1707

wants to merge 6 commits into from

Conversation

yg-cho
Copy link

@yg-cho yg-cho commented Jul 23, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@chrisjune chrisjune self-requested a review July 24, 2025 01:16
Copy link

@chrisjune chrisjune left a comment

Choose a reason for hiding this comment

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

고생하셨습니다
코멘트를 남기지 않은 문제는 저와 풀이가 너무 유사해서 놀랐습니다 ㅎㅎ

* @return {boolean}
*/
var containsDuplicate = function(nums) {
return new Set(nums).size !== nums.length;

Choose a reason for hiding this comment

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

전 개수를 세서 2개이상인지 판단했는데 set을 이용한건 되게 좋은 아이디어네요

let longest = 0;

for (const num of numSet) {
if(!numSet.has(num-1)) {

Choose a reason for hiding this comment

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

자바스크립트는 익숙치 않아서 제가 제대로 이해한진 잘 모르겠습니다
의도가 numSet을 순회하면서 더 작은게 없는지 체크하는 용도로 쓰신 if절이라면
순회 전에 numSet을 sort하면 if문을 사용하지 않아도 될것 같아요. 근데 시간복잡도를 생각해보면 if문이 더 유리할 수 있겠어요!

저도 처음엔 중첩루프로 풀었는데요, dynamic programming을 이용해서 nums와 동일한 크기의 배열을 만들고
배열값이 현재까지의 최대연속된 숫자의 개수로 업데이트하는 방식으로 풀면 단일루프로도 풀 수 있더라고요

Copy link
Author

Choose a reason for hiding this comment

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

안녕하세요.
sort를 하기 보다, 현재 숫자보다 작은 num-1이 존재하지 않으면 현재 숫자가 이전 보다 작으니 시작점으로 보고, 해당 값부터 증가해 나가면서 연속된 횟수를 찾았습니다.
어떤 순서로 순회하든 모든 시작점을 다 찾게 되고, 순서는 결과에 영향이 없다고 생각하여 sort하진 않았습니다.

리뷰 감사합니다~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Solving
Development

Successfully merging this pull request may close these issues.

2 participants