Your question is K-th Largest Element. 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.
Glance needs to identify a score threshold for ranking content in a feed. Given an unsorted array of integers nums and an integer k, return the k-th largest element in nums.
The largest element is the 1st largest, and duplicate values count as separate elements. You may modify the input array during processing.
nums, a non-empty list of integers, and k, a 1-indexed integer.nums.O(n) time and O(1) auxiliary space by using an in-place selection algorithm.def kth_largest(nums, k):