What's the problem? Python


  • 0
    P

    My code is:

    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            nums = filter(lambda x: x != 0, nums) + filter(lambda x: x == 0, nums)
    

    My input is [0,1,0,3,12]

    My answer [0,1,0,3,12]

    Why??, I don't know why don't work the filter function, any ideas??. In a terminal in python this working very well..!, the response is [1,3,12,0,0], so.. what happened here =(.. Thank you so much! =)

    PS: Sorry for my English!


  • 1
    A

    you filter will return a new list.
    the question requires to do it in place.


  • 0
    P

    Thank you.!. I changed all code.! haha, I like more the old solution that the new, but it's ok. The problem was that!! Thank you again!


Log in to reply
 

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