Simple Python code

  • 0
    class Solution(object):
        def removeDuplicates(self, nums):
            if not nums:
                return 0
            if len(nums) == 1:
                return 1
            for i in range(len(nums)-1, 0, -1):
                if nums[i] == nums[i-1]:
                    del nums[i]
            return len(nums)

Log in to reply

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