public void nextPermutation(int[] num) {
            if (num.length <= 1) {
                return;
            }
            int i = num.length - 1;
            while (i > 0) {
                i--;
                if (num[i] < num[i + 1]) {
                    int j = num.length;
                    while (num[--j] <= num[i]) {
                    }
                    swap(num, i, j);
                    reverse(num, i + 1, num.length);
                    return;
                }
            }
            reverse(num, 0, num.length);
        }