
In a Meta-style ranking pipeline, you may need the kth largest score from an unsorted list without fully sorting it. Given an integer array nums and an integer k, return the kth largest element in the array.
The kth largest element is the value that would appear at position k in a descending sort, counting duplicates as separate elements.
nums: a list of integersk: an integer where 1 <= k <= len(nums)kth largest element in numsExample 1
nums = [3, 2, 1, 5, 6, 4], k = 25[6, 5, 4, 3, 2, 1], so the 2nd largest element is 5.Example 2
nums = [3, 2, 3, 1, 2, 4, 5, 5, 6], k = 44[6, 5, 5, 4, 3, 3, 2, 2, 1], so the 4th largest element is 4.1 <= len(nums) <= 10^5-10^4 <= nums[i] <= 10^41 <= k <= len(nums)nums = [3, 2, 1, 5, 6, 4], k = 2Output5WhyThe descending order is `[6, 5, 4, 3, 2, 1]`, so the 2nd largest value is `5`.nums = [3, 2, 3, 1, 2, 4, 5, 5, 6], k = 4Output4WhyThe descending order is `[6, 5, 5, 4, 3, 3, 2, 2, 1]`, so the 4th largest value is `4`.nums = [7], k = 1Output7WhyWith one element, the 1st largest is the element itself.1 <= len(nums) <= 10^5-10^4 <= nums[i] <= 10^41 <= k <= len(nums)The array may contain duplicate valuesdef find_kth_largest(nums, k):