The problem. Given an integer array nums and an integer k, return the kth largest element — the kth largest in sorted order, so duplicates count separately, not the kth distinct value. 1 ≤ k ≤ nums.length.
nums = [3, 2, 1, 5, 6, 4], k = 2 -> 5
nums = [3, 2, 3, 1, 2, 4, 5, 5, 6], k = 4 -> 4 (6, 5, 5, 4: duplicates count)
nums = [7], k = 1 -> 7Free account
Sign up to read the rest of this lesson: 6 more sections, 3 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come