Heaps, Sorting & Searching
Binary search, sorting, and the top-k toolkit.
Binary search is the most under-used interview weapon - and it works on more than sorted arrays. Combine it with a solid grasp of sorting and the heap-based top-k patterns, and a whole category of problems opens up.
Lessons in this stage
- 01
Binary Search, Really Understood
AdvancedThe template that avoids off-by-one bugs, why the midpoint is written (lo + hi) >>> 1, and how to find boundaries, not just exact matches.
16 min - 02
Binary Search on the Answer
AdvancedThe advanced trick: when a problem asks to minimize a maximum (or vice versa) and feasibility is monotonic, binary-search the answer itself.
15 min - 03
Sorting Essentials
IntermediateMerge sort and quicksort at a glance, why Java uses each, stability, and the times when sorting first is the whole solution.
15 min - 04
Heaps & Top-K
AdvancedA heap of size k finds the k largest, k closest, or k most frequent in O(n log k) - without sorting everything.
15 min - 05
Quickselect & Partitioning
AdvancedFind the k-th smallest element in O(n) average time using quicksort's partition step - without fully sorting.
13 min