There are N balls in a row. The \(i^{th}\) ball has color \(A_i\). You have to destroy all of the balls by using the following operation any number of times.
Operation: Let the current number of balls be k. All the balls of color k are destroyed at the same moment. Given the different scenarios, tell whether you will be able to destroy all the balls or not.
Input Format:
First line contains t, the number of test cases.
Each of the test case contains an integer N, the number of balls.
Next line contains N space separated integers corresponding to the color of balls.
Output Format:
For each test case, print “YES”(without quotes) if all balls can be destroyed otherwise “NO”.
Constraints
\(1≤ t ≤ 200\)
\(1≤N≤1000\)
\(1≤A_i≤1000000000\)
Initially, there are 6 balls. Now, all balls having color equal to 6 are destroyed together at the same moment. Now, there are 3 balls remaining.
All balls having color equal to 3 are destroyed together at this moment. Now, there is only 1 ball remaining. All balls having color equal to 1 are destroyed together at this moment.
After this operation, all balls have been destroyed. Thus, the answer is yes.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor