标签:[] public turn bsp nbsp else col div code
用优先队列
public PriorityQueue<Integer> kthLargest(int k, int[]a) { PriorityQueue<Integer> q = new PriorityQueue<>(k); for (int i : a) { if (q.size() < k) { q.offer(i); }else { if (i > q.peek()) { q.poll(); q.offer(i); } } } return q; }
标签:[] public turn bsp nbsp else col div code
原文地址:https://www.cnblogs.com/gaoquanquan/p/10848261.html