Leetcode 26. Remove Duplicates from Sorted Array

class Solution:
    def removeDuplicates(self, nums):
        if len(nums) == 0:
            return 0
        i = 0
        for j in range(1,len(nums)):
            if nums[j] != nums[i]:
                i+=1
                nums[i] = nums[j]
        del nums[i+1:]
        return i+1

 本题加强版:

Leetcode 80

posted @ 2019-04-25 00:49  周洋  阅读(313)  评论(0编辑  收藏  举报