public int[] medianII(int[] nums) {
        if (nums == null || nums.length == 0)
            return null;
        int[] ans = new int[nums.length];
        int initSize = 10;
        PriorityQueue<Integer> min = new PriorityQueue<Integer>();
        PriorityQueue<Integer> max = new PriorityQueue<Integer>(initSize, new Comparator<Integer>() {
            public int compare(Integer x, Integer y) {
                return y - x;
            }
        });
        ans[0] = nums[0];
        max.offer(nums[0]);
        for (int i = 1; i < nums.length; ++i) {
            int val = max.peek();
            if (nums[i] > val) {
                min.offer(nums[i]);
            } else {
                max.offer(nums[i]);
            }
            if (max.size() > min.size() + 1) {
                min.offer(max.poll());
            } else if (max.size() < min.size()) {
                max.offer(min.poll());
            }
            ans[i] = max.peek();
        }
        return ans;
    }