🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 7 - Heaps and Priority QueuesPractice QuestionsOverview

Heap Practice Questions

Ten classic heap problems. Every one of them is the same sentence in disguise: “of these many things, give me the most extreme one — repeatedly.” Recognize that pattern and a heap becomes the obvious tool.

All the solutions below use the standard library’s priority queue rather than rolling our own heap. That’s the right call in real code — the implementation is identical and well-tested. We covered the from-scratch version on the Operations page.

Easy

ProblemPatternStatus
Last Stone WeightRepeatedly extract the two largestAvailable
Kth Largest Element in an ArraySize-K min-heapAvailable
Kth Largest Element in a StreamOnline size-K min-heapAvailable

Medium

ProblemPatternStatus
Top K Frequent ElementsHash count + size-K min-heapAvailable
K Closest Points to OriginSize-K max-heap of distancesAvailable
Sort Characters by FrequencyCounter + heap (or bucket)Available
Task SchedulerMax-heap + cooldown queueAvailable
Reorganize StringMax-heap by frequencyAvailable

Hard

ProblemPatternStatus
Merge K Sorted ListsMin-heap of list headsAvailable
Find Median from Data StreamTwo heaps (max + min)Available

More Practice (Coming Soon)

ProblemPatternStatus
Sliding Window MedianTwo heaps with lazy deletionComing Soon
Connect Ropes with Minimum CostMin-heap, repeated mergingComing Soon
IPO / Maximum CapitalTwo heaps (capital + profit)Coming Soon
Furthest Building You Can ReachMin-heap of brick costsComing Soon
Smallest Range Covering K ListsK-way merge with heapComing Soon
Single-Threaded CPUMin-heap by (processing time, id)Coming Soon
Maximum Performance of a TeamMin-heap, greedy iterationComing Soon