Top K Problems
Learn Top K Problems (Heap, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The General "Top K" Pattern A huge family of interview problems reduces to the same shape: maintain a heap of size K, evicting the "weakest" candidate whenever a better one shows up. Beyond raw numbers, this works for ANY object with a defined priority - most frequent elements, closest points, cheapest flights.