← All problems
SetEasy
Contains Duplicate
SetEasy
Step 1 of 8 · Understand
1. Understand the problem
Given a list of integers, return true if any value appears more than once in the list, or false if every value is unique.
Input
An array of integers `nums`.
Output
A boolean — `true` if any number appears at least twice, `false` if all numbers are distinct.
Examples
input → nums = [1, 2, 3, 1]
output → true
1 appears at index 0 and index 3.
input → nums = [1, 2, 3, 4]
output → false
All values are different.
input → nums = [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]
output → true
Multiple values repeat.
Write your solution above and hit Run tests. Results and tips appear here.