0031. Next Permutation
Find the next lexicographically greater permutation of an array
Load
Example 1: [1,2,3]
Example 2: [3,2,1]
Example 3: [1,1,5]
Long: [1,5,8,4,7,6,5,3,1]
Swap: [2,3,1]
Mid: [1,3,5,4,2]
Scanning
Descending suffix
Pivot
Swap target
Swapped
Reversing
Done
Click "Step" or "Play" to begin
Step
Play
Pause
Reset
Speed:
800ms
Ready. Load an array and click Step or Play.
Result
—