Contains Duplicate
Given an integer array nums, return true if any value appears at least twice, and false if every element is distinct.
Open official problem prompt ↗Decide whether the array contains any repeated element.
Like collecting unique stamps into an album: if you end with fewer distinct stamps than pieces of paper you handled, some stamp was a repeat.
- Input
- nums = [1, 2, 3, 1]
- Output
- true
- Why
- The value 1 appears at index 0 and index 3, so a duplicate exists.
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9