class Solution:
    def removeDuplicates(self, nums: 'List[int]') -> 'int':
        if not len(nums):
            return 0
        i = 1
        while True:
            try:
                if nums[i - 1] == nums[i]:
                    nums.pop(i)
                else:
                    i += 1
            except:

                return i


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