LeeMax117 / LeetCode_practise

recorde our Leetcode process
0 stars 1 forks source link

31. Next permutation #8

Closed nijilong1224 closed 5 years ago

nijilong1224 commented 5 years ago

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).

The replacement must be in-place and use only constant extra memory.

Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.

1,2,3 → 1,3,2 3,2,1 → 1,2,3 1,1,5 → 1,5,1

LeeMax117 commented 5 years ago

https://github.com/LeeMax117/LeetCode_practise/tree/master/LeeMax/31_next_permutation

nijilong1224 commented 5 years ago

https://github.com/LeeMax117/LeetCode_practise/blob/master/Jinglong/nextPermutation.py