Skip to content

Glossary: Coding Interviews in Rust

Heap for top k

Also written: top k

Keeping a heap of only k items and dropping the weakest whenever it grows past k. This costs O(n log k), cheaper than sorting everything when k is small.

Where the book teaches it

Related terms

BinaryHeapReverse