Skip to content

Glossary: Coding Interviews

heapq

Also written: heapq.nlargest, heapq.nsmallest, nlargest, nsmallest, heap

Python's heap module. `nlargest` and `nsmallest` return the top k items by a `key`, in O(n log k).

Where the book teaches it

Related terms

Top kLambda