Skip to content

Conversation

@WHYjun
Copy link
Contributor

@WHYjun WHYjun commented Nov 8, 2025

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@WHYjun WHYjun moved this from Solving to In Review in 리트코드 스터디 6기 Nov 8, 2025
@haxr369 haxr369 self-requested a review November 10, 2025 11:11
return len(numsSet)

# Use priority queue to sort in O(n)
sorted = []
Copy link
Contributor

Choose a reason for hiding this comment

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

sorted는 파이썬 내장 정렬 함수라, 같은 이름의 변수를 정의하면 함수 참조가 가려집니다.
이후에 sorted 호출 시 혼동을 일으킬 수 있으니, pq 같은 변수명을 사용하는게 좋을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그렇네요. 인터뷰용으로만 쓰다 보니 이런 부분을 놓치네요. 감사합니다.

for num in numsSet:
heapq.heappush(sorted, num)

prev = heapq.heappop(sorted)
Copy link
Contributor

Choose a reason for hiding this comment

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

힙큐를 이용해 단순 정렬을 원하시면 heapify로 힙을 구성한 뒤, sorted()로 정렬하는 편이 더 효율적이고, 단순 sorted(numSet)을 호출하셔도 동일한 결과를 얻으실 수 있으십니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

감사합니다. 일단 heapify로 해두었습니다. 기록용으로 heapq 풀이법 먼저 생각해두었던 것을 남겨둔 거라서요.

@haxr369
Copy link
Contributor

haxr369 commented Nov 12, 2025

네~! 고생하셨습니다!

Copy link
Contributor

@haxr369 haxr369 left a comment

Choose a reason for hiding this comment

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

네! 고생하셨어요!
남은 한주 파이팅입니다!

@WHYjun WHYjun merged commit a7426ad into DaleStudy:main Nov 13, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 6기 Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants