CS-Notes
CS-Notes copied to clipboard
题解-排序Kth Largest Element in an Array翻译有误
Kth Largest Element in an Array:数组中第k大的元素
Hello @KLSMDN is anyone assigned for this issue? It would be glad if I could be assigned to it and make my contribution. Thanks
class Solution { public int findKthLargest(int[] nums, int k) { PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder()); for(int i:nums){ pq.add(i); } int q=1; while(q!=k){ pq.poll(); q++; } return pq.poll(); } }