Next permutation

Implement next permutation:

1,2,3 -> 1,3,2

3,2,1 -> 1,2,3

1,1,5 -> 1,5,1

actually it's utilizing full tree property.

{
                        1[15]        5[11]            
                        /  \        /               
                     11[5]  15[1]  51[1] 
                     /        \     /
                 115         151   511               
}

Solution 1 : Brute Force

Solution 2: Tricky

next permutation means "next permutation has no permutation" between current and next.

eg. 7 8 6 9 8 7 2

Palindrome permutation

results matching ""

    No results matching ""