217. Contains Duplicate
Description
See https://leetcode.com/problems/contains-duplicate/
Solutions
There are numerous solutions to this problem. Here are a few.
Solution 1
Space O(N), Time O(N) - from creating the set
Solution 2
Space O(N), Time O(N)
Solution 3
This would be the slowest solution as it has the overhead of sorting the list.
Space O(N), Time O(N log N) - Time complexity for sort. See: https://wiki.python.org/moin/TimeComplexity
Last updated