Why my code doesnt work in Python? keeping saying Time Limit Exceeded. Thank you for helping


  • 0
    S

    class Solution(object):
    def containsDuplicate(self, nums):
    y=[]
    for i in nums:
    if i not in y:
    y.append(i)
    else:
    y
    if len(y)<len(nums):
    return True
    else:
    return False


  • 0
    P

    use backsticks for your code space
    i dont under stand that y between 'else' and 'if len < len'


Log in to reply
 

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