class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) <= 1:
return len(nums)
flag = nums[0]
length = 1
for num in nums[1::]:
if flag != num:
flag = num
nums[length] = flag
length += 1
return length