#C11556. Check for Duplicates in Arrays
Check for Duplicates in Arrays
Check for Duplicates in Arrays
Given an array of integers, determine if the array contains any duplicate elements. The task is to check if any value appears at least twice in the array. If duplicates exist, output True
; otherwise, output False
.
You will be given multiple test cases. For each test case, the first line contains an integer \(N\) representing the number of elements in the array. The second line contains \(N\) space-separated integers.
The mathematical condition for duplicates can be expressed as: \(\text{if } |A| \neq |\text{set}(A)|\) then duplicates exist.
Please note that the input should be processed from standard input (stdin) and output must be printed to standard output (stdout).
inputFormat
The input begins with an integer \(T\) on the first line, indicating the number of test cases. Each test case follows with two lines:
- The first line contains an integer \(N\) representing the size of the array.
- The second line contains \(N\) space-separated integers representing the elements of the array.
All input should be read from standard input (stdin).
outputFormat
For each test case, output a single line containing True
if the array contains duplicates, and False
otherwise.
Output each result on a new line to standard output (stdout).
## sample2
5
1 2 3 4 5
4
1 2 3 1
False
True
</p>