python leetcode 26. Remove Duplicates from Sorted Array

在原本数组上操作即可

class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        ln = len(nums)
        if ln==0:
            return 0
        j=0  
        for i in range(1,ln):
            if nums[j] != nums[i]:
                nums[j+1]=nums[i]
                j=j+1 
        return j+1

猜你喜欢

转载自blog.csdn.net/Neekity/article/details/84864358