#K48972. Longest Mixed Parity Subarray
Longest Mixed Parity Subarray
Longest Mixed Parity Subarray
Given an array of n integers, your task is to determine the length of the longest contiguous subarray in which no two consecutive elements have the same parity. In other words, for any two adjacent elements in the subarray, one must be odd and the other must be even.
If the array consists of a single element, the answer is 1. Parity is determined by whether a number is odd or even.
Note: The input is given via standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The first line of input contains a single integer n
representing the number of elements in the array. The second line contains n
space-separated integers.
outputFormat
Output a single integer representing the length of the longest contiguous subarray such that no two consecutive elements in the subarray are of the same parity.
## sample1
10
1
</p>