public void add(int num) {
        if(minHeap.size() == 0 && maxHeap.size() == 0) {
            maxHeap.offer(num);
            return;
        }

        if(minHeap.size() == 0) {
            if(maxHeap.peek() > num) {
                minHeap.offer(maxHeap.poll());
                maxHeap.offer(num);
            } else {
                minHeap.offer(num);
            }
            return;
        }

        int min = minHeap.peek();
        int max = maxHeap.peek();

        if(minHeap.size() == maxHeap.size()) {
            if(num < max) {
                maxHeap.offer(num);
            } else if(num > min) {
                minHeap.offer(num);
                maxHeap.offer(minHeap.poll());
            } else {
                maxHeap.offer(num);
            }
        } else {
            if(num < max) {
                maxHeap.offer(num);
                minHeap.offer(maxHeap.poll());
            } else if(num > min) {
                minHeap.offer(num);
            } else {
                minHeap.offer(num);
            }
        }
    }