← All problems

Kth Largest Element in an Array

Medium heapsquickselect LeetCode ↗
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.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.