def removeDuplicates(self, nums): # write your code here if nums == []: return 0 index,count = 0, 1 for i in range(1, len(nums)): if nums[index] == nums[i] and count < 2: index += 1 count += 1 nums[index] = nums[i] if nums[index] != nums[i]: index += 1 count = 1 nums[index] = nums[i] return index+1