#C3762. Taco Sequence Puzzle
Taco Sequence Puzzle
Taco Sequence Puzzle
You are given a set of tiles, each with an integer number written on it. The goal is to determine whether it is possible to arrange the tiles in such a way that the difference between any two adjacent numbers is exactly 1. In other words, after sorting the tiles, the sequence should satisfy the condition (a_i - a_{i-1} = 1) for every adjacent pair. For example, the sequence [4, 2, 1, 3] can be rearranged into [1, 2, 3, 4], which is valid, but [10, 11, 13] cannot form a consecutive sequence.
This problem requires you to process multiple test cases. The input is given through standard input (stdin) and the result for each test case should be printed to standard output (stdout).
inputFormat
The first line contains an integer (T) denoting the number of test cases. For each test case, the first line contains a single integer (N) representing the number of tiles, followed by a line with (N) space-separated integers (a_1, a_2, \dots, a_N) describing the numbers on the tiles.
outputFormat
For each test case, output a single line containing the string "YES" if it is possible to form a valid consecutive sequence, otherwise output "NO".## sample
5
4
4 2 1 3
3
10 11 13
5
-1 1 0 -2 2
1
2
5
2 3 4 5 6
YES
NO
YES
YES
YES
</p>