29. Next Permutation
MediumArray
A permutation of an array of integers is an arrangement of its members into a sequence or linear order. The next permutation of an array of integers is the next lexicographically greater permutation of its integer. If such an arrangement is not possible, the array must be rearranged as the lowest possible order (i.e., sorted in ascending order). Given an array of integers nums, find the next permutation of nums. The replacement must be in place and use only constant extra memory.
Examples
Input: [1,2,3]
Output: [1,3,2]
Explanation: The next lexicographically greater permutation of [1,2,3].
Constraints
- 1 <= nums.length <= 100
- 0 <= nums[i] <= 100
Loading...
Run checks all cases above. Submit evaluates all test cases.