75. Sort Colors
# Medium

Solution:
if
nums[i] = 0, swap(nums[p0], nums[i]), p0 and i move forward one stepif
nums[i] = 2, swap(nums[i], nums[p2]), p2 move back one stepif
nums[i] = 1, only i move forward one step
最难想的是nums[i] = 1该怎么处理,跳过即可,但是不能挪p0指针
Time complexity = , space complexity =
Last updated
Was this helpful?