class Solution:
def sortColors(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
first=0
third=len(nums)-1
i=0
while i<=third:
if nums[i]==0:
nums[first],nums[i]=nums[i],nums[first]
first+=1
i+=1
elif nums[i]==2:
nums[third],nums[i]=nums[i],nums[third]
third-=1
else:
i+=1
第二种情况i不移动