Back to DSA sheet
Contains Duplicate
EasyArraysGiven an array of integers, report whether any value appears more than once. Print true if at least one value repeats, otherwise false.
Input format (stdin): the first line has the integer n. The second line has n integers. Output the lowercase word true or false.
Examples
Input: 4
1 2 3 1
Output: true
The value 1 appears twice.
Input: 4
1 2 3 4
Output: false
Every value is distinct.
Constraints
- 1 <= n <= 10^5
- -10^9 <= nums[i] <= 10^9
Sheets
Blind 75NeetCode 150NeetCode 250
contains-duplicate.cpp3 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.