28. K Largest Elements
EasyPriority queues & heaps
Return the k largest elements of nums in descending order. Repeated values count separately.
Example 1
Input: nums = [3, 1, 5, 12, 2, 11], k = 3 Output: [12, 11, 5]
Constraints
0 ≤ k ≤ nums.length ≤ 10⁵