Python solution not working.


  • 0
    P

    I have the code working in Local. but i get the following error

    Line 41: TypeError: range() integer end argument expected, got list.

    class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        isSecond = False
        ele = -1
        arr = nums
        itemsTobeRemoved = []
        for i in arr:
            if ele != i:
                isSecond = False
                ele = i
            elif not isSecond:
                isSecond = True
            else:
                itemsTobeRemoved.append(i)
        for item in itemsTobeRemoved:
            arr.remove(item)
        return arr
    

    Please suggest where i am doing it wrong. Thanks in advance.


  • 0
    P

    The solution works perfectly in Ideone too.

    http://ideone.com/SXSbpG


  • 0
    S

    You should return the length of the new array, not the new array itself


Log in to reply
 

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