Contains Duplicate
Problem
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:
Pseudocode
Solution
Time and Space Complexity
Time
Loop through array once, add number to set - O(N)
Total - O(N)
Space
Store number in a set - O(N)
Total - O(N)
Last updated