1 class Solution(object): 2 def removeDuplicates(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 i = 0 8 while i < len(nums)-1: 9 if nums[i] != nums[i+1]: 10 i += 1 11 elif nums[i] == nums[i+1]: 12 nums.pop(i+1) 13 return len(nums) 14 15 if __name__ == '__main__': 16 solution = Solution() 17 print(solution.removeDuplicates(nums=[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))