What's wrong with my python solution?


  • 0
    Y
    class Solution(object):
        def removeDuplicates(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            res = []
            for item in nums:
                if item not in res:
                    res.append(item)
            
            nums = res
            return len(nums)
    

    Why wrong?


  • 0
    W

    use: nums[:] = res


Log in to reply
 

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