Kth Largest Element in an Array

Try to solve the Kth Largest Element in an Array problem.

Statement

Find the kthk^{th} largest element in an unsorted array.

Note: We need to find the kthk^{th} largest element in the sorted order, not the kthk^{th} distinct element.

Constraints:

  • 1≤1 \leq k ≤\leq nums.length ≤103\leq 10^3

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

Examples

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy