215. Kth Largest Element in an Array

Practice Kth Largest Element in an Array for free on NudgeCode: Medium, Heap pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the k-th largest value in nums, counting duplicates separately: in [3,3,1] the 1st and 2nd largest are both 3. Try to do better than sorting the whole array.

Example

nums = [3,2,1,5,6,4], k = 2        ->  5
nums = [3,2,3,1,2,4,5,5,6], k = 4  ->  4

Constraints