#C1594. Odd-Length Even-Sum Subarray
Odd-Length Even-Sum Subarray
Odd-Length Even-Sum Subarray
Given an array of integers, your task is to determine whether there exists a contiguous subarray of odd length whose sum is even. Formally, for an array \(a_1,a_2,\dots,a_n\), you need to decide if there exist indices \(i\) and \(j\) (with \(1 \le i \le j \le n\)) such that the length \(L = j-i+1\) is odd and the sum \(\sum_{k=i}^{j}a_k\) is even.
If such a subarray exists, output YES
; otherwise, output NO
.
inputFormat
The input begins with a single integer \(T\) (the number of test cases). For each test case, the first line contains an integer \(n\) representing the length of the array. The second line contains \(n\) space-separated integers representing the elements of the array.
Input Format:
T n a1 a2 ... an [repeated T times]
outputFormat
For each test case, print a single line containing YES
if there exists a contiguous subarray of odd length with an even sum, or NO
otherwise.
2
4
1 2 3 4
3
1 3 5
YES
NO
</p>