Next Permutation

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 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. The replacement must be in place and use only constant extra memory.

Constraints

  • 1 <= nums.length <= 100
  • 0 <= nums[i] <= 100
Saving… · 2 lines
class Solution:
def nextPermutation(self, nums: List[int]) -> None:
Console

Click Run to execute sample tests.