Rearrange nums into the lexicographically next greater permutation. If no next permutation exists (descending order), rearrange to the lowest order (ascending). Must be in-place.
Example 1:
Input: 1 2 3 Output: 1 3 2
Example 2:
Input: 3 2 1 Output: 1 2 3
Input format: Space-separated integers.
Output format: Space-separated integers.