Pattern Recognition Drill
Easy Heaps
The Problem
Demonstrate pushing and popping elements from a min-heap.
What approach would you use?
Think about it before scrolling down.
heapq.heappush inserts in O(log n), heappop removes min in O(log n). Array-based complete binary tree.
Common Trap
Python's heapq is a min-heap. For max-heap, negate values or use a wrapper.