```
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) < 3:
return len(nums)
p1, p2 = 0, 2
l = len(nums)
while p2 < l:
while nums[p2] == nums[p1]:
nums.pop(p2)
l -= 1
if p2 == l:
break
p1 += 1
p2 = p1 + 2
return len(nums)
```

My code will modify the nums, by removing all duplicates that are more than twice.