#C5216. Longest Balanced Subarray
Longest Balanced Subarray
Longest Balanced Subarray
Given an array of integers, your task is to find the length of the longest balanced subarray in which the number of even numbers is equal to the number of odd numbers. In mathematical terms, a subarray is balanced if $$\#even = \#odd$$.
The problem consists of multiple test cases. For each test case, you are given the size of the array followed by the array elements. Your solution should determine the maximum length of any contiguous subarray that satisfies the balanced condition.
inputFormat
The first line of input contains an integer T representing the number of test cases. For each test case:
- A line containing an integer N, the number of elements in the array.
- A line containing N space-separated integers, representing the array elements.
outputFormat
For each test case, output the length of the longest balanced subarray on a new line.
## sample5
6
1 2 3 4 5 6
4
1 4 2 3
5
2 4 6 8 10
5
1 3 5 7 9
7
1 2 1 2 1 2 1
6
4
0
0
6
</p>