Courses/Collections & Stdlib Toolbox

๐Ÿงฐ Collections & Stdlib Toolbox

heapq โ€” priority queues

Min-heap on a plain list.

heapq keeps the smallest item at index 0 in O(log n). nsmallest / nlargest are handy for top-k.

main.py
Output
Press Run to execute.
Expected output
1
[1, 3, 5]

Sign in to track your progress across lessons.