๐งฐ 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.
๐งฐ Collections & Stdlib Toolbox
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.
Press Run to execute.1 [1, 3, 5]
Sign in to track your progress across lessons.