Uber - Coding round 1 - for SDE II

"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.

ex- arr[4]=[4,5,5,5]

ans= we have only [1,2] subarray which satisfy this so ans=1
contraints: N<= 10^5"

Feel free to post the answer or link to the answer

Try to find an O(N) solution

Comments (5)