mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
@ -168,7 +168,8 @@ class Solution:
|
|||||||
Do not return anything, modify nums in-place instead.
|
Do not return anything, modify nums in-place instead.
|
||||||
"""
|
"""
|
||||||
length = len(nums)
|
length = len(nums)
|
||||||
for i in range(length - 1, -1, -1):
|
for i in range(length - 2, -1, -1): # 从倒数第二个开始
|
||||||
|
if nums[i]>=nums[i+1]: continue # 剪枝去重
|
||||||
for j in range(length - 1, i, -1):
|
for j in range(length - 1, i, -1):
|
||||||
if nums[j] > nums[i]:
|
if nums[j] > nums[i]:
|
||||||
nums[j], nums[i] = nums[i], nums[j]
|
nums[j], nums[i] = nums[i], nums[j]
|
||||||
|
Reference in New Issue
Block a user