public class Solution {
public int findKthLargest(int[] nums, int k) {
PriorityQueue que = new PriorityQueue(
new Comparator() {
public int compare(Integer o1, Integer o2) {
if(o1 < o2) {
return 1;
} else if (o1 > o2) {
return -1;
} else {
return 0;
}
}
}
);
for(int i : nums) {
que.offer(i);
}
for(int i = 0; i < k - 1; i++) {
que.poll();
}
return que.poll();
}
public class Solution { public int findKthLargest(int[] nums, int k) { PriorityQueue que = new PriorityQueue(
new Comparator() {
public int compare(Integer o1, Integer o2) {
if(o1 < o2) {
return 1;
} else if (o1 > o2) {
return -1;
} else {
return 0;
}
}
}
);
} 这个网址很强 https://segmentfault.com/a/1190000003704825