언어
명예의 전당
땅호720
2023. 12. 15. 17:46
우선순위 큐 활용
import heapq
def solution(k, score):
answer = []
klist = []
for s in score:
if len(klist) >= k:
heapq.heappushpop(klist, s)
else:
heapq.heappush(klist, s)
minnum = klist[0]
answer.append(minnum)
return answer