← All problems
Kth Largest Element in an Array
Find the kth largest element in an unsorted array without fully sorting it. Compare the heap-based approach with the selection-algorithm approach and their trade-offs.
Complexity
Time O(n log k) heap / O(n) avg quickselect, Space O(k)
Common pitfalls
- Max-heap of everything (O(n log n))
- Quickselect worst-case O(n^2) unmentioned
Your solution
Log in to save your code and track progress.