Skip to content

Glossary: Coding Interviews in Java

Heap / PriorityQueue

Also written: PriorityQueue, min-heap, max-heap, heap, top k

Java's `PriorityQueue` is a min-heap with the smallest item on top. Keeping a heap of size k and dropping the smallest each time finds the top k in O(n log k).

Where the book teaches it

Related terms

Comparator