private int[] selectMaxNumber(int[] nums, int n) {
        int[] stack = new int[n];
        int top = -1;
        for (int i = 0; i < nums.length; ++i) {
            while (top >= 0 && nums[i] > stack[top] && nums.length - i >= n - top) --top;
            if (top + 1 < n) stack[++top] = nums[i];
        }
        return stack;
    }