import java.util.*;
public class Solution {
public int findKth(int[] a, int n, int k) {
//使用小根堆
PriorityQueue<Integer> heap = new PriorityQueue<>(k);
//先将k个元素放入堆中
for(int i=0;i<k;i++){
heap.add(a[i]);
}
for(int i=k;i<n;i++){
if(heap.peek()<a[i]){
heap.poll();
heap.add(a[i]);
}
}
return heap.peek();
}
}