#C3954. Check for Duplicates
Check for Duplicates
Check for Duplicates
You are given one or more test cases. For each test case, you are provided with an array of integers. Your task is to determine whether the array contains any duplicate elements.
If an array has any element that appears more than once, print YES
; otherwise, print NO
.
For example, consider the test case:
1 6 1 2 3 4 5 3
Since the number 3 appears twice, the correct answer would be YES
.
Note: The input will be provided in stdin and the output should be produced to stdout. Ensure that your solution handles input/output in this manner.
Mathematically, if we denote the array as \(A = [a_1, a_2, \dots, a_n]\), then the condition to decide if duplicates exist can be written as:
[ \exists, i, j ; (1 \le i < j \le n \land a_i = a_j) ]
inputFormat
The input starts with a single integer \(T\) denoting the number of test cases. Each test case is described as follows:
- The first line contains an integer \(N\) denoting the number of elements in the array.
- The second line contains \(N\) space-separated integers representing the elements of the array.
All inputs are read from stdin.
outputFormat
For each test case, output a single line containing YES
if the array contains any duplicates; otherwise, output NO
. All outputs should be written to stdout.
3
5
1 2 3 4 5
4
1 1 2 3
6
10 20 30 20 50 60
NO
YES
YES
</p>