#C5390. Almost Equal Array
Almost Equal Array
Almost Equal Array
You are given an array of integers. Your task is to determine whether there exists a pair of adjacent integers (after sorting the array) whose difference is exactly 1. If such a pair exists, output "YES"; otherwise, output "NO".
Note: Duplicate numbers are allowed. However, the pair used to decide should consist of two numbers that differ by exactly one, after sorting.
Example:
For an array [1, 2, 3]: After sorting, the array remains [1, 2, 3]. Since 2 - 1 = 1, the answer is "YES".
inputFormat
The first line contains a single integer T, the number of test cases.
For each test case, the first line contains an integer n, the size of the array.
The following line contains n space-separated integers representing the array elements.
outputFormat
For each test case, output a single line containing either "YES" or "NO" depending on whether there exists any two adjacent elements in the sorted array that differ by exactly 1.
## sample4
3
1 2 3
4
1 1 1 1
5
5 5 5 5 5
6
1 2 2 3 3 4
YES
NO
NO
YES
</p>