๐ฎ Heaps (Practice)
Companion to the Heaps & Priority Queues guide. Watch a min-heap build by sifting each new value up, then use heapq for top-K.
๐ฌ Watch it workโ
Min-Heap Insert โ sift upStep 1 / 21
Insert 7 at index 0
๐ Your turnโ
Loading editorโฆ
๐ง Challenge yourselfโ
- Build a max-heap using the negate trick.
- Implement a streaming median with two heaps.
- Why is
heapifyO(n) but k pushes O(n log n)?
Continue the path โ Trees & BST