You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are given an array A of N positive integer values. A subarray of this array is called Odd-Even subarray if the number of odd integers in this subarray is equal to the number of even integers in this subarray.
Find the number of Odd-Even subarrays for the given array.
Input Format:
The input consists of two lines.
First line denotes N - size of array.
Second line contains N space separated positive integers denoting the elements of array A.
Output Format:
Print a single integer, denoting the number of Odd-Even subarrays for the given array.
Logic Used: for subarray (i,j):
even[i]-even[j-1]=odd[i]-odd[j-1]
this implies that
even[i]-odd[i]=even[j-1]-odd[j-1]
We store default value of 1 for 0
then we proceed forward as saving evencount-oddcount and then applying the formula