[
hash table
]
Leetcode 0217. Contains Duplicate
Problem statement
https://leetcode.com/problems/contains-duplicate/
Solution
In python just create set and check that length of this set is equal to the original length, oneliner.
Complexity
Complexity, both time and memory is O(n).
Code
class Solution:
def containsDuplicate(self, nums):
return len(set(nums)) != len(nums)