Kth Largest Element in an Array

Heap · Keep only the k most relevant values · Stretch · about 24 min

Why it matters

Top-k problems are a common place where a heap is clearer than sorting everything.

How it connects

A heap chose the next largest item. A small heap can now preserve only the best k candidates.

Try first

If you only care about k largest values, which value should be easiest to remove?

Interview cue

The heap stays size k, so the work is O(n log k), not a full sort.