Skip to content

Latest commit

 

History

History
20 lines (20 loc) · 555 Bytes

26.md

File metadata and controls

20 lines (20 loc) · 555 Bytes

26. Remove Duplicates from Sorted Array

题目链接

class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums) <= 1:
            return len(nums)
        flag = nums[0]
        length = 1
        for num in nums[1::]:
           if flag != num:
                flag = num
                nums[length] = flag
                length += 1
        return length