A web-vitals report shows the k-th slowest page load in a sample (for example, the 50th slowest out of 10,000 loads, which approximates the p99.5). Write kthLargest(values, k), which returns the k-th largest value in values, where k = 1 is the maximum.
Duplicates count separately: in [5, 5, 3] the 1st and 2nd largest are both 5.
kthLargest([1200, 340, 980, 4100, 760], 1); // 4100
kthLargest([1200, 340, 980, 4100, 760], 2); // 1200
kthLargest([5, 5, 3], 2); // 5
kthLargest([7], 1); // 7
kthLargest([3, -1, 2], 3); // -1
1 ≤ k ≤ values.length.values. The report reuses the array.Spotted a mistake or a rights concern? Report an issue