26. Remove Duplicates from Sorted Array

class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if not nums:
            return 0
        
        flag=0
       
        for i in range(1,len(nums)):
            if nums[flag]!=nums[i]:
                flag+=1
                nums[flag]=nums[i]
        return flag+1
                
原文地址:https://www.cnblogs.com/xlqtlhx/p/8052169.html