-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Chaedie] Week 1 #625
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
[Chaedie] Week 1 #625
Conversation
@Chaedie 와, 3기 두 번째 PR의 주인공이 되셨네요. 🥈 축하드립니다! 👏 |
@DaleSeo 축하해주셔서 감사합니다. 꾸준히 진행해서 꼭 완주하도록 하겠습니다..! 😀 |
@Chaedie 님, 권한 이슈가 해결되어 다행입니다! |
contains Duplicate 문제 set으로 변환해서 기존 배열이랑 길이가 다르면 true 같으면 false... |
@GotPrgmer 저도 다른 분 솔루션 통해 얻은 관점입니다. 다양한 좋은 솔루션들이 많더라구요... 감사합니다..! |
Time Complexity: | ||
1. remove duplicate by hash set -> O(n) | ||
2. sort the list -> O(n log n) | ||
3. iterate sorted_nums -> O(n) | ||
|
||
so time complexity of this solution will be O(n log n) | ||
|
||
Space Complexity: | ||
1. set() -> O(n) | ||
2. sorted_nums -> O(n) | ||
3. count , maxCount -> O(1) | ||
|
||
space complexity of this solution will be O(n) |
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.
Big O 분석 정성스럽게 해주시는 것 아주 모범적입니다 :) bb
for num in nums: | ||
counts[num] += 1 | ||
|
||
result = sorted(counts.items(), key=lambda x: x[1], 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.
python의 built-in sort 알고리즘을 찾아보니 Timsort
라는 것을 사용하는 것 같은데, 이게 merge sort
의 일종이라는 것을 알게 되었습니다 (링크)
결과적으로 해당 풀이의 space complexity가 변하진 않겠지만, space complexity 고려에 해당 sort기능의 space complexity인 O(N)이 포함되면 더 좋았을 것 같습니다 :)
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.
wow 감사합니다.
Timsort의 time complexity 는 검색해서 추가했지만, Space complexity 는 전혀 고려하지 않았습니다.
짚어주셔서 감사합니다..!
if char.isalnum(): | ||
string.append(char) | ||
|
||
return string == string[::-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.
이 부분도 최종적인 space complexity에는 영향을 미치지 않지만, string[::-1]
의 space complexity까지 고려해주시면 더 좋을 것 같습니다 :)
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.
@obzva 리뷰 감사합니다..!
리뷰사항 반영해서 Commit 했습니다.
감사합니다.
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.