## Solutions ### Hash Table ```python class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ num_set = set() for num in nums: if num in num_set: return True num_set.add(num) return False ``` - we initialize a empty set (a type of hash table without key: value but only the elements) to store the appeared number - iterate the array - if a number in the set which means it appeared before, return True - if it's not which means it's the first time it shows up, we store it into the set - if the iteration finished and none of numbers every appeared twice, it means we don't have any duplicate in the set, return False - Time complexity: On, iterate the arrary - Space complexity: On, we need to store the whole array in the worst situation