Next Permutation

Medium
Arrays Array Two Pointers

Rearrange to next lexicographically greater permutation. If last, first.

Constraints

1 ≤ nums.length ≤ 100

Examples

Example 1:
Input: 1 2 3
Output: 1 3 2
Example 2:
Input: 3 2 1
Output: 1 2 3
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.