-
-
Notifications
You must be signed in to change notification settings - Fork 195
[thispath98] Week 1 #660
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
[thispath98] Week 1 #660
Conversation
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.
수고하셨습니다. 대세에 큰 지장이 없는 코멘트만 남겼습니다.
class Solution: | ||
def topKFrequent(self, nums: List[int], k: int) -> List[int]: | ||
count_dict = Counter(nums) | ||
top_k_list = count_dict.most_common(k) |
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.
실제 코딩 인터뷰에서 다른 프로그래밍 언어에서 흔히 볼 수 없는 표준 라이브러리를 사용할 경우 해당 언어를 잘 모르는 면접관을 만날 경우 양날의 검으로 작용할 수 있으니 주의바라겠습니다.
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.
넵 감사합니다! 사실 sort를 이용해서 구현했었는데, Counter 메소드를 사용하는 게 성능이 더 좋아서 첨부했습니다. 다음부터는 여러 시행착오도 업로드해보겠습니다 ㅎㅎ
num_dict = {} | ||
for num in nums: | ||
if num not in num_dict: | ||
num_dict[num] = 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.
사전에 저장하는 값의 종류가 한 가지인데, 이런 경우에는 세트를 쓰는 게 더 적합하지 않을까 생각이 들었습니다.
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.
코멘트 감사합니다!
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.