Medium · Hash Maps
Find Kth largest
Given an integer array a and an integer k, 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
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.