You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Solution {
public int findKthLargest(int[] nums, int k) {
PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
for(int i:nums){
pq.add(i);
}
int q=1;
while(q!=k){
pq.poll();
q++;
}
return pq.poll();
}
}
Kth Largest Element in an Array:数组中第k大的元素
The text was updated successfully, but these errors were encountered: