Python easy solution use two-pointer method


  • 0
    J
        def removeDuplicates(nums):
            if not nums:return 0
            jj = 1
            for ii in xrange(1,len(nums)):
                if nums[jj-1]!=nums[ii]:
                    nums[jj] = nums[ii]
                    jj +=1
                ii +=1
            return jj
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.