Contains Duplicate
Easy · hash map
Given a list of integers nums, return True if any value appears at least twice in the list. Return False if every value is different.
You only need a yes or no answer. You do not have to say which value repeats or where it is. A list with a single number can never have a repeat, so the answer there is False.
Examples
Example 1
Input: nums = [1, 2, 3, 1]
Output: True
The value 1 appears at index 0 and again at index 3.
Example 2
Input: nums = [1, 2, 3, 4]
Output: False
Every number appears exactly once.
Example 3
Input: nums = [3, 3, 3, 3]
Output: True
Constraints
- 1 <= len(nums) <= 10^5
- -10^9 <= nums[i] <= 10^9