Given an array arr[] and a number k. The task is to find the kth largest element in the array.
Example 1
Input: arr[] = [10, 20, 4, 45, 99], k = 2
Output: 45
Explanation: The elements in the array sorted in descending order are: [99, 45, 20, 10, 4]. The 2nd largest element is 45.
Example 2
Input: arr[] = [1, 7, 8, 3, 9, 2], k = 4
Output: 3
Explanation: The elements in the array sorted in descending order are: [9, 8, 7, 3, 2, 1]. The 4th largest element is 3.
Sign in to write, run, and submit your solution against the full test suite.