Which heap keeps the top k?
Warm-up · Multiple choice · about 2 min
You stream one million numbers and must keep the 10 largest seen so far, using as little memory as possible. Which heap do you keep?
Learn the idea first: Priority queues in practice: top-k, k-way merge, scheduling, a visual lesson.
More Priority queues in practice: top-k, k-way merge, scheduling problems
- K largest values Warm-up
- Last stone weight Warm-up
- Merge k sorted lists Standard
- Top k frequent values Standard
- Trace a size-k min-heap Standard
- Task scheduler Challenge