Python ma duplikaty
def has_duplicates(lst):
return len(lst) != len(set(lst))
x = [1,2,3,4,5,5]
has_duplicates(x) # True
VasteMonde
def has_duplicates(lst):
return len(lst) != len(set(lst))
x = [1,2,3,4,5,5]
has_duplicates(x) # True
#most efficient solution on Leet code
def containsDuplicate(self,nums)->bool:
d={}
for ele in nums:
if ele not in d:
d[ele] = 1
else:
return True
return False
def checkDuplicate(user):
if len(set(user)) < len(user):
return True
return False