CS-Notes icon indicating copy to clipboard operation
CS-Notes copied to clipboard

题解-排序Kth Largest Element in an Array翻译有误

Open KLSMDN opened this issue 2 years ago • 2 comments

Kth Largest Element in an Array:数组中第k大的元素

KLSMDN avatar Feb 27 '23 08:02 KLSMDN

Hello @KLSMDN is anyone assigned for this issue? It would be glad if I could be assigned to it and make my contribution. Thanks

pranjalisr avatar Mar 12 '23 15:03 pranjalisr

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(); } }

AmanBansal1706 avatar Mar 29 '23 15:03 AmanBansal1706