#coding=utf-8
# 解题思路: 关键点:变量逻辑状态的定义 20190302 找工作期间
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return None
k = 0
value = nums[0]
count = 1
for i in range(1,len(nums)):
if count < 2:
if nums[i] == value:
count += 1
k += 1
nums[k] = nums[i]
else:
k += 1
nums[k] = nums[i]
value = nums[k]
count = 1
else:
if nums[i] != value:
k += 1
nums[k] = nums[i]
value = nums[k]
count = 1
return k+1
nums = [1,1,1,2,2,3]
nums2 = [0,0,1,1,1,1,2,3,3]
# [0,0,1,1,2,1,2]
# [0,0,1,1,2,3,3]
s = Solution()
n1 =s.removeDuplicates(nums2)
print n1
print nums2