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.
Glossary: Coding Interviews in Rust
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.