#C2011. Check Odd Sum Subarray
Check Odd Sum Subarray
Check Odd Sum Subarray
Given an array \(b\) of positive integers with length \(m\), determine if there exists a contiguous subarray whose sum is odd. Note that a single element is also considered a contiguous subarray. Formally, you need to check if there exist indices \(l\) and \(r\) (with \(1 \le l \le r \le m\)) such that
[ \sum_{i=l}^{r} b_i \equiv 1 \pmod{2} ]
If such a subarray exists, output YES
; otherwise, output NO
.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\) denoting the number of test cases.
- For each test case, the first line contains an integer \(m\) — the number of elements in the array.
- The second line contains \(m\) space-separated positive integers representing the array \(b\).
outputFormat
For each test case, print a single line to standard output (stdout) containing YES
if there exists at least one contiguous subarray with an odd sum, or NO
otherwise.
4
5
2 4 6 1 3
3
8 10 12
4
1 2 4 6
6
7 2 9 1 14 3
YES
NO
YES
YES
</p>