Alternating Parity Stretch
Find the longest contiguous stretch where the values alternate between even and odd at every step.
Input: the first line has N; the second line has N integers.
Output: the maximum length of an alternating-parity stretch.
Constraints:
- 1 ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
6 2 1 4 7 6 6
Output 1
5
Input 2
1 3
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.