https://leetcode.com/problems/kth-largest-element-in-a-stream/description/


class KthLargest {
int k;
PriorityQueue<Integer> heap = new PriorityQueue<>();
public KthLargest(int k, int[] nums) {
this.k = k;
for(int n : nums) {
add(n);
}
}
public int add(int val) {
heap.add(val);
if (heap.size() > k) {
heap.poll();
}
return heap.peek();
}
}
k번째로 큰 수 -> k 크기의 min-heap에서 가장 처음 수