Back to Home
Heaps
Heaps maintain quick access to the minimum or maximum element.
Key Ideas
- Use a min-heap for smallest-first retrieval and a max-heap for largest-first.
- Great for top-k, k-way merge, and streaming medians.
- Many problems use a heap plus a hash map for lazy deletion.
Practice Problems
Kth Largest Element in an Array
LeetCodeMedium
Practice this problem with interactive visualization.
Start Solving
Top K Frequent Elements
LeetCodeMedium
Practice this problem with interactive visualization.
Start Solving
K Closest Points to Origin
LeetCodeMedium
Practice this problem with interactive visualization.
Start Solving