class Solution {
PriorityQueue<Integer> min = new PriorityQueue<>();
PriorityQueue<Integer> max = new PriorityQueue<>((a,b)->b-a);
public void insert(Integer num) {
max.add(num);
min.add(max.remove());
if(min.size() > max.size()) {
max.add(min.remove());
}
}
public Double getMedian() {
if(max.size() == min.size()){
return (max.peek() + min.peek()) / 2.0;
}else {
return max.peek() * 1.;
}
}
}