Next PermutationMedium

array two pointers

Rearrange nums in place into the next lexicographically greater permutation. Find the pivot, swap with its next-larger successor, then reverse the suffix — watch it run step by step.

Press play to watch the algorithm run.
Metrics
Legend
How it works
0 / 0