반응형
야근 지수
-
8. 힙(heap)코딩테스트 2024. 3. 21. 23:10
명예의 전당(1) - https://school.programmers.co.kr/tryouts/85933/challenges heapq 모듈의 기본 사용법 활용 → heapify, heappush, heappop from heapq import heappush, heappop, heapify def solution(k, score): heap = [] heapify(heap) ans = [] for s in score: heappush(heap, s) if len(heap) > k: heappop(heap) ans.append(heap[0]) return ans 더 맵게 - https://school.programmers.co.kr/tryouts/85934/challenges 불가능한 경우 예외 처리 주..