We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 75e1bb2 commit 1598341Copy full SHA for 1598341
problems/0031.下一个排列.md
@@ -120,7 +120,22 @@ class Solution {
120
```
121
122
## Python
123
-
+>直接使用sorted()不符合题意
124
+```python
125
+class Solution:
126
+ def nextPermutation(self, nums: List[int]) -> None:
127
+ """
128
+ Do not return anything, modify nums in-place instead.
129
130
+ for i in range(len(nums)-1, -1, -1):
131
+ for j in range(len(nums)-1, i, -1):
132
+ if nums[j] > nums[i]:
133
+ nums[j], nums[i] = nums[i], nums[j]
134
+ nums[i+1:len(nums)] = sorted(nums[i+1:len(nums)])
135
+ return
136
+ nums.sort()
137
+```
138
+>另一种思路
139
```python
140
class Solution:
141
'''
0 commit comments