Back to Home
Heaps
4 practice problemsInteractive visual guide
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
LeetCode: https://leetcode.com/problems/kth-largest-element-in-an-array/
Start Solving
Top K Frequent Elements
LeetCodeMedium
LeetCode: https://leetcode.com/problems/top-k-frequent-elements/
Start Solving
K Closest Points to Origin
LeetCodeMedium
LeetCode: https://leetcode.com/problems/k-closest-points-to-origin/
Start Solving