grokking-algorithms/chapter9/examples/heaptest.py

11 lines
244 B
Python
Raw Normal View History

2023-12-19 15:47:26 +00:00
import heapq
customers = []
heapq.heappush(customers, (2, "Harry"))
heapq.heappush(customers, (3, "Charles"))
heapq.heappush(customers, (1, "Riya"))
heapq.heappush(customers, (4, "Stacy"))
while customers:
print(heapq.heappop(customers))