Why my python solution doesn't work when input = [0] ?


  • -1
    M
    class Solution(object):
        def sortColors(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            if len(nums) > 0:
                return filter(lambda x:x==0,nums)+filter(lambda x:x==1,nums)+filter(lambda x:x==2,nums)
            else:
                return None

  • 0
    M

    Input: [0]
    Output: Do not return anything, modify nums in-place instead.
    expected: [0]


  • 0

    You have a return statement.

    From the comments,

    :rtype: void Do not return anything, modify nums in-place instead.

Log in to reply
 

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