#K68907. Contiguous Sequence Formation
Contiguous Sequence Formation
Contiguous Sequence Formation
You are given t test cases. For each test case, you are provided with an integer n and a sequence of n integers. Your task is to determine if the sequence can be reordered to form a contiguous sequence of increasing numbers.
A contiguous sequence means that when the sequence is sorted, every two consecutive elements differ by exactly 1, i.e., if the sorted sequence is \(a_1, a_2, \ldots, a_n\), then for every \(i\) (\(1 \le i < n\)), \(a_{i+1} = a_i + 1\). If this condition holds, output "YES"; otherwise, output "NO" for that test case.
Note: The input is taken from standard input and the output should be printed to standard output.
inputFormat
The first line of input contains an integer t, the number of test cases. The description of t test cases follows.
For each test case:
- The first line contains an integer n, the number of elements in the sequence.
- The second line contains n space-separated integers representing the sequence.
outputFormat
For each test case, print a single line containing "YES" if the sequence can be reordered to form a contiguous sequence of increasing numbers, otherwise print "NO".
## sample3
4
4 2 3 1
5
6 2 4 3 1
3
10 11 12
YES
NO
YES
</p>