Merged
Conversation
93f6e8c to
de844cf
Compare
…ments and longestConsecutiveSequence
| # counts.get gets the count of num | ||
| # reverse=True sorts in descending order | ||
| # [:k] gets the first k elements | ||
| top_nums = sorted(counts, key=counts.get, reverse=True) |
Contributor
There was a problem hiding this comment.
파이썬에서는 딕셔너리에 대해 sorted를 쓸 수 있군요! 덕분에 자바의 TreeMap 자료구조에 대해서도 공부해볼 수 있었습니다 (비록 이 문제에는 적용하기 어렵지만 ㅎㅎ)
Comment on lines
+12
to
+20
| # only start counting if it's the beginning of a sequence | ||
| if num - 1 not in num_set: | ||
| current_num = num | ||
| current_streak = 1 | ||
|
|
||
| # keep counting while the next number in the sequence exists | ||
| while current_num + 1 in num_set: | ||
| current_num += 1 | ||
| current_streak += 1 |
Contributor
There was a problem hiding this comment.
연속 수열의 시작부터 보는 방법이 있었네요
저는 괜히 어렵게 생각했네요 😅 좋은 아이디어 배우고 갑니다!
Member
|
@yolophg 님, 재수생 티나요 😛 우리 3기 부터는 Draft PR 안 쓰기로 했습니다. 프로젝트의 상태로 충분히 커뮤니케이셔니 가능한 부분이라서요. |
SamTheKorean
approved these changes
Dec 15, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
체크 리스트
In Review로 설정해주세요.