UberOA #62
Top-K Using a Priority Queue
估计中等评测数据准备中,可先阅读题面
考点(AI 标注)单调栈与堆
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.