Medium · Hash Maps
Find Kth largest
Given a non-empty integer array a and an integer k with 1 ≤ k ≤ length(a), return the k-th largest element of a, counting duplicates separately (the k-th value when a is sorted in descending order).
Examples
Example 1
[3,2,1,5,6,4], k=2Output: 2nd largest = 5
Example 2
[3,2,3,1,2,4,5,5], k=4Output: 4th largest = 3
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.