Python solution


  • 0
    B
    class Solution(object):
        def removeDuplicates(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            if len(nums) == 0:
                return 0
            i = 1
            for n in nums:
                if n > nums[i-1]:
                    nums[i] = n
                    i += 1
            nums = nums[:i]
            return i
    

Log in to reply
 

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