Python solution using del


  • 0
    L
    class Solution(object):
        def removeDuplicates(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            curr=len(nums)
            i=1
            while i<len(nums):
                if nums[i]==nums[i-1]:
                    curr-=1
                    del nums[i-1]
                else:
                    i+=1
            return curr

Log in to reply
 

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