Your question is Kth Largest Without Sorting. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Tencent Video analytics may need a ranking threshold from an unsorted batch of engagement scores without fully ordering every score. Given an unsorted integer array and an integer k, return the kth largest element, counting duplicate values as separate elements.
You must not sort the entire array. Modify nums in place if needed, and use an algorithm that achieves average O(n) time.
Implement find_kth_largest(nums, k):
nums, a mutable list of integers, and k, a 1-based integer rank.k when the array is ordered from largest to smallest.def find_kth_largest(nums, k):