题目:
题解:
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
idx, left, right = 0, 0, 0
while left < len(nums):
nums[idx] = nums[left]
idx += 1
while right < len(nums) and nums[right] == nums[left]:
right += 1
if right - left > 1:
nums[idx] = nums[left]
idx += 1
left = right
return idx