← 返回 capitalone 的题目列表Count alternating odd/even subarrays
类型:online_judge
Given an array of numbers, count the number of subarrays where odd and even numbers alternate.
Example
Input: [1, 3, 2, 4] Output: 3
Explanation: Following are the odd-even alternating subarrays: [3, 2], [1, 3, 2], [3, 2, 4].
Constraints
Array length is between 1 and 10^5
All numbers are positive integers.
Example
Input
[1, 3, 2, 4]
Output
3