Heapq Module: Efficient Priority Queue Operations
TL;DR
The heapq module provides heap queue (priority queue) operations using a binary heap implemented as a list, where heappush()
and heappop()
maintain the heap invariant with O(log n) complexity.