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