```
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not len(nums):
return 0
i = 0
for j in range(1, len(nums)):
if nums[j-1] == nums[j]:
continue
else:
nums[i] = nums[j-1]
i += 1
if nums[-1] != nums[i-1]:
nums[i] = nums[-1]
return i+1
```