public void heapify(int[] nums, int len) {
        int n = len;
        for (int i = n / 2; i >= 1; --i) {
            int k = i, val = nums[k];
            while (2 * k <= n) {
                int child = 2 * k;
                if (child < n) {
                    // there exist two child, and get the larger child
                    if (nums[child] < nums[child + 1]) {
                        child += 1;
                    }
                }
                if (nums[k] >= nums[child]) {
                    break;
                } else {
                    swap(nums, k, child);
                    k = child;
                }
            }
        }
    }