Contains Duplicate — Arrays & Hashing
Decide whether any integer in a list occurs at least twice, and report yes or no.
Arrays & Hashing · Easy
The problem
Given a list of integers, say whether any value shows up more than once.
What to return
- Return true if some value appears at least twice, otherwise false.
- Large hidden tests (up to 400 numbers) run under a step budget of executed lines.
Constraints
- 0 ≤ len(nums) ≤ 400
- −10⁴ ≤ nums[i] ≤ 10⁴
- Your code may run at most 4,812 counted steps on the largest case.
Example
- Input
nums = [1, 2, 3, 1]- Output
true