Contains Duplicate
EasyArrays & Hashing
Given an integer array nums, return True if any value appears at least twice. Return False if every value appears only once.
Example 1
- Input:
- nums = [8,4,2,8]
- Output:
- True
- Explanation
- 8 appears at index 0 and again at index 3.
Example 2
- Input:
- nums = [3,1,4,15,9]
- Output:
- False
- Explanation
- All five values are different, so nothing repeats.
Example 3
- Input:
- nums = [-3,0,4,-3,10]
- Output:
- True
- Explanation
- -3 appears twice. Negative values are compared like any other.
Constraints
- 1 ≤
nums.length≤ 105 - -109 ≤
nums[i]≤ 109