UberOA #62
Top-K Using a Priority Queue
Estimated MediumStatement and editorial — judging is being prepared
Topics (AI-labelled)Stacks & Heaps
Given an integer array nums and an
Constraints
1 ≤ nums.length ≤ 2 * 10⁵-10⁹ ≤ nums[i] ≤ 10⁹1 ≤ k ≤ nums.length
Example 1
Input:
nums = [3, 2, 1, 5, 6, 4]
k = 2
Output:
[5, 6]
Explanation:
The two largest values are 5 and 6. Any order is acceptable.
Editorial
Loading solution…