Core Patterns
Heaps & Top-K
Always know the smallest (or largest) item in O(1) and update in O(log n). Heaps power top-k, k-way merge, running medians and schedulers.
0 of 3 lessons complete, 0 of 7 problems solved
Coursework
37 min
Up next
What a Heap Is
A complete binary tree packed into a list that keeps the minimum on top.
11 min
heapq: Max-Heaps, Priorities and Top-K
Drive Python's min-heap like a pro and keep the k best items in O(n log k).
13 min
K-Way Merge, Two Heaps and Scheduling
Three heap patterns that show up again and again in interviews.
13 min
Practice ladder
Start with the first problem, then work toward the harder variations. Run examples before submitting against all tests.
Next unit: Backtracking