Next Permutation Generator

Rearrange numbers into the next lexicographically greater permutation or smallest if not possible.

Examples
Input: [1,2,3]
Output: [1,3,2]
Hints

Next Permutation Generator

Rearrange numbers into the next lexicographically greater permutation or smallest if not possible.