Concept Flow - Next Permutation of Array
Start from end
Find pivot i where arr[i
If no pivot found
Reverse whole array
→Done
No
Find successor j where arr[j
Swap arr[i
Reverse suffix from i+1 to end
Done
Find the first decreasing element from the right, swap it with the next bigger element on the right, then reverse the suffix to get the next permutation.
