One line python solution went wrong


  • -1
    C

    My solution is:
    return len(set(A))
    I tested it right in my own IDE, but was told wrong when I submit. Can someone please tell me why?


  • 0
    R

    It requires no new list be created. Did you do that?


  • 0
    M

    That's not a solution and it's not in place. If you really wanna make it work copy contents of your solution over the old array. Also with sets you have no guarantee that the order will be preserved. Think about it a bit


  • 0
    H

    cause you didn't change the list A itself. It is required to do so in place.


Log in to reply
 

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