This code passes only 13/16 test cases.Can't figure out what's wrong.


  • 0
    P

    def containsDuplicate(self, nums):

     if nums == list(set(nums)):
            return False
        else:
            return True

  • 2
    T

    The order in a set is not really something that can be guaranteed. Your logic is good (converting to a set to remove duplicates because yay python), but see if you can come up with a different way to verify that the set of a list doesn't match the list itself.


Log in to reply
 

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