#C11523. Contains Duplicate
Contains Duplicate
Contains Duplicate
Given an integer array of size n, determine whether the array contains duplicate elements. In other words, check if there exists any value that appears at least twice in the array. If duplicates exist, output True
; otherwise, output False
. For a formal definition, we require that there exist indices \( i \) and \( j \) (with \( i \neq j \)) such that \( a_i = a_j \), which can be written in LaTeX as: $$\exists\, i, j\ (i\neq j \text{ and } a_i=a_j).$$
inputFormat
The first line contains an integer ( n ) (with ( n \ge 0 )), representing the number of elements in the array. The second line contains ( n ) space-separated integers.
outputFormat
Print True
if any duplicate exists in the array, otherwise print False
.## sample
4
1 2 3 1
True