Skip to content

[yerim01] WEEK 01 solutions#2365

Merged
yerim01 merged 2 commits intoDaleStudy:mainfrom
yerim01:main
Mar 7, 2026
Merged

[yerim01] WEEK 01 solutions#2365
yerim01 merged 2 commits intoDaleStudy:mainfrom
yerim01:main

Conversation

@yerim01
Copy link
Contributor

@yerim01 yerim01 commented Mar 3, 2026

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

Copy link
Contributor

@hyejj19 hyejj19 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 +4 to +7
# Approach:
# - Use a hash set to track elements we have already seen.
# - Iterate through the array and if the current number already exists in the set, return True.
# - Otherwise, add the current number to the set.
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 +29 to +44
for c in nums:
currentL = 1
j = 1

while c+j in s:
s.remove(c+j)
currentL += 1
j += 1

j = 1
while c-j in s:
s.remove(c-j)
currentL += 1
j += 1

longest = max(longest, currentL)
Copy link
Contributor

Choose a reason for hiding this comment

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

오! 기준 원소 c를 기준으로 양쪽을 제거해서 중복 탐색을 방지하는 의도군요!👍👍

근데 기준점인 c는 set에서 제거되지 않아서, 다음 반복에서 이웃 원소로 발견되어서 불필요한 탐색이 될 수도 있을 것 같습니다! for문에서 자기 자신을 제거하는 로직을 먼저 추가하고 시작하는건 어떨까요?

저는 이 문제를 c-1 이 없을 때 해당 원소를 연속된 숫자의 시작이라고 보고, 거기서부터 +1 하면서 longest 를 세는 방식으로 풀었는데 set을 제거 안하고 풀 수 있어서 좀 더 깔끔해질 수 있을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

제시해주신 방법이 더 나을것 같네요 감사합니다!

@yerim01 yerim01 merged commit b6d6593 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.

2 participants