Contains Duplicate
Last updated
Last updated
Given an integer array
nums
, returntrue
if any value appears at least twice in the array, and returnfalse
if every element is distinct.
Example 1:
Example 2:
Example 3:
Loop through array once, add number to set - O(N)
Total - O(N)
Store number in a set - O(N)
Total - O(N)