Next permutation
Mediumarraytwo pointersmath
Return the next arrangement of nums in lexicographic order. If this is the last arrangement, return the first (ascending). Do it in place.
Example 1
Input: nums = [1,2,3] Output: [1,3,2]
Example 2
Input: nums = [3,2,1] Output: [1,2,3]
Example 3
Input: nums = [1,1,5] Output: [1,5,1]
Constraints
- 1 ≤ nums.length ≤ 100
- 0 ≤ nums[i] ≤ 100
Submit checks your solution against 10 tests, including hidden ones.
/**
* @param {int[]} nums
* @return {int[]}
*/
function nextPermutation(nums) {
}