Heap Sort
Build a heap from the list, then repeatedly pull out the largest element to sort in place in O(n log n).
Heap Sort Practice Problems
Easy
2 problemsMedium
3 problems- 84medium
Top K Frequent Elements
Find the k most frequently occurring elements in an array.
- 85medium
Kth Smallest Element in a Sorted Matrix
Find the kth smallest value in a matrix where each row and column is sorted.
- 86medium
K Closest Points to Origin
Find the k points closest to the origin on a 2D plane.
Hard
2 problemsRelated concepts
| Topic | Description |
|---|---|
| Bubble Sort | Repeatedly swap neighboring out-of-order elements until the whole list is sorted, simple but slow on large lists. |
| Merge Sort | Split the list in half, sort each half, then merge them back together in order, giving reliable O(n log n) time. |
| Quick Sort | Pick a pivot, move smaller elements left and larger ones right, then repeat on each side to sort in place. |
| Insertion Sort | Build the sorted list one element at a time, inserting each new element into its correct position as you go. |
| Selection Sort | Repeatedly find the smallest remaining element and move it into place, simple to write but slow on large lists. |
| Counting Sort | Count how many times each value appears, then rebuild the list in order, sorting in O(n) when values fall in a small range. |