Medium · Binary Search
Kth Largest Element in an Array
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
Open every published interview problem, solution, scene, and memory room free, with no account.