mycode  69.20%

class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        pos = 0
        for i in range(1,len(nums)):
            if nums[i] == nums[i-1]:  
                continue
            pos += 1
            nums[pos] = nums[i]
            #print(pos,nums[pos],item,nums)
        nums[:] = nums[:pos+1]
        return pos + 1

 

参考:

思路和我的差不多,就是用一个标识符去记录重复项被非重复项覆盖的位置

def removeDuplicates(A):
        if len(A) == 0:
            return 0
        j = 0
        for i in range(0, len(A)):
            if A[i] != A[j]:
                A[i], A[j+1] = A[j+1], A[i]
                j = j + 1
        return j+1

removeDuplicates([0,0,1,1,1,4,5,6,6])