题目:
题解:
class Solution:def nextPermutation(self, nums: List[int]) -> None:i = len(nums) - 2while i >= 0 and nums[i] >= nums[i + 1]:i -= 1if i >= 0:j = len(nums) - 1while j >= 0 and nums[i] >= nums[j]:j -= 1nums[i], nums[j] = nums[j], nums[i]left, right = i + 1, len(nums) - 1while left < right:nums[left], nums[right] = nums[right], nums[left]left += 1right -= 1