-
-
Notifications
You must be signed in to change notification settings - Fork 245
[Helena] Week 1 #690
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
[Helena] Week 1 #690
Conversation
93f6e8c
to
de844cf
Compare
…ments and longestConsecutiveSequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔하게 풀이해주셔서 추가로 드릴만한 코멘트는 없습니다 (제가 파이썬을 잘 모르기도 하구요.. 😵)
House Robber 풀이도 올려주시면 리뷰하겠습니다
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파이썬에서는 딕셔너리에 대해 sorted를 쓸 수 있군요! 덕분에 자바의 TreeMap 자료구조에 대해서도 공부해볼 수 있었습니다 (비록 이 문제에는 적용하기 어렵지만 ㅎㅎ)
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
연속 수열의 시작부터 보는 방법이 있었네요
저는 괜히 어렵게 생각했네요 😅 좋은 아이디어 배우고 갑니다!
@yolophg 님, 재수생 티나요 😛 우리 3기 부터는 Draft PR 안 쓰기로 했습니다. 프로젝트의 상태로 충분히 커뮤니케이셔니 가능한 부분이라서요. |
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.