Why my two-line python solution cannot be accepted?


  • 0
    M
    def sortColors(nums):
        if len(nums) != 0:
            return filter(lambda x: x == 0, nums) + filter(lambda x: x == 1, nums) + filter(lambda x: x == 2, nums)

  • 0

    What error do you get?


  • 0
    M

    input: [0]
    output: void Do not return anything, modify nums in-place instead.
    expect: [0]
    thanks for your reply


  • 0

    Ok. I couldn't tell because you also removed the self, from the signature, which causes a different error.

    Anyway... is it clear now? I mean, that error message tells you exactly what to do and what not to do.


Log in to reply
 

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