LeetCode 31. Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
The replacement must be in place and use only constant extra memory.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= nums.length <= 100
0 <= nums[i] <= 100
Solution
PreviousLeetCode 30. Substring with Concatenation of All WordsNextLeetCode 32. Longest Valid Parentheses
Last updated