Concept Flow - Next Permutation of Array
Start from end
Find first i where arr[i
Yes
Find j from end where arr[j
Swap arr[i
Reverse subarray from i+1 to end
Done
Reverse whole array
Done
Find the first decreasing element from the right, swap it with a just larger element on the right, then reverse the tail to get the next permutation.
