public void nextPermutation(int[] num) {
        if (num == null || num.length <= 1) {
            return;
        }
        
        int i = num.length - 1;
        while (i >=1 && num[i] <= num[i-1]) {
            i--;
        }
        /* last permutation (complete descending order) -> first permutation */
        if (i == 0) {
            reverse(num, 0, num.length - 1);
            return;
        }
        /*  */
        int start = i - 1;
        int pivot = num[i-1];
        while (i < num.length && num[i] > pivot) {
            i++;
        }
        swap(num, start, i- 1);
        reverse(num, start + 1, num.length - 1);
    }