Medium · Binary Search
Kth Largest Element in an Array (Reference problems)
Given an integer array nums and an integer k, return the kth largest element: the element at position k when the array is sorted in descending order, with duplicates counted separately.
Examples
Example 1
[3,2,1,5,6,4], k=2 → 5Output: 5
Example 2
[3,2,3,1,2,4,5,5,6], k=4 → 4Output: 4
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.