#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