Skip to content

Conversation

thispath98
Copy link
Contributor

@thispath98 thispath98 commented Dec 9, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@thispath98 thispath98 requested a review from jinah92 December 9, 2024 12:38
@thispath98 thispath98 requested a review from a team as a code owner December 9, 2024 12:38
@github-actions github-actions bot added the py label Dec 9, 2024
Copy link
Member

@DaleSeo DaleSeo left a 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)
Copy link
Member

Choose a reason for hiding this comment

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

실제 코딩 인터뷰에서 다른 프로그래밍 언어에서 흔히 볼 수 없는 표준 라이브러리를 사용할 경우 해당 언어를 잘 모르는 면접관을 만날 경우 양날의 검으로 작용할 수 있으니 주의바라겠습니다.

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

사전에 저장하는 값의 종류가 한 가지인데, 이런 경우에는 세트를 쓰는 게 더 적합하지 않을까 생각이 들었습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

코멘트 감사합니다!

@thispath98 thispath98 merged commit aaecd51 into DaleStudy:main Dec 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants