You are given an array A containing N integers. Find if it is possible to rearrange the elements of the array such that the parity of the sum of each pair of adjacent elements is equal (formally, \(parity(A_i + A_{i+1}) = parity(A_{j} + A_{j+1})\) for each \(1 \leq i \lt j \leq N-1\) ).
Here, parity refers to the remainder obtained when a number is divided by 2 (i.e. \(parity(x) = x \mod 2\)).
Input format
- The first line contains T denoting the number of test cases. The description of T test cases is as follows:
- For each test case:
- The first line contains N denoting the size of array A.
- The second line contains N space-separated integers A[1], A[2], ....., A[N] - denoting the elements of A.
Output format
For each test case, print "YES"(without quotes) if it is possible to reorder the array elements to satisfy the given condition and "NO"(without quotes) otherwise.
Constraints
\(1 \leq T \leq 100 \\ 1 \leq N \leq 100\\ 1 \le A_i \le 100\)
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