Concept Flow - Next Permutation of Array
Start from right end
Find first i where arr[i
Yes
Find j from right where arr[j
Swap arr[i
Reverse subarray from i+1 to end
Done - next permutation found
No
Reverse whole array - last permutation reached
Find the next bigger arrangement by swapping and reversing parts of the array.
