# Time: O(n)
# Space: O(1)
# Remove Dupicates from sorted Array
'''
0 1 2 3 4
[1,1,2,2,3]
last = 0
i = 1
'''
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
last, i = 0, 1
while i < len(nums):
if nums[last] != nums[i]:
last += 1
nums[last] = nums[i]
i += 1
return last + 1