题目:
题解:
class Solution:def sortColors(self, nums: List[int]) -> None:n = len(nums)p0, p2 = 0, n - 1i = 0while i <= p2:while i <= p2 and nums[i] == 2:nums[i], nums[p2] = nums[p2], nums[i]p2 -= 1if nums[i] == 0:nums[i], nums[p0] = nums[p0], nums[i]p0 += 1i += 1