c++
class Solution {
public:
priority_queue<int> que;
int findKthLargest(vector<int>& nums, int k) {
for (int x : nums) que.push(x);
while (--k) {
que.pop();
}
return que.top();
}
};
js
var findKthLargest = function(nums, k) {
var que = new MaxPriorityQueue();
for (var x of nums) que.enqueue('x', x);
while (--k) {
que.dequeue()['priority'];
}
return que.dequeue()['priority'];
};