개발 공부 기록

[python] heapq 본문

취업 준비/코딩테스트

[python] heapq

_김도연 2020. 9. 13. 00:58

module import

import heapq

heap 생성

heap = []

원소 추가, 삭제

heapq.heappush(heap, 값) # 추가
print(heapq.heappop(heap)) # 삭제

응용

heapq.heappush(heap, (우선순위, 값))

 

 

참고

www.daleseo.com/python-heapq/

Comments