Odd-Even Subarrays
Practice
4.2 (126 votes)
Algorithms
Dynamic programming
Easy
Problem
93% Success 30740 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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.

Constraints:

  • \(1 \leq N \leq 2 \times 10^5\)
  • \(1 \leq A[i] \leq 10^9\)

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
16 votes
Tags:
AlgorithmsBrute-force searchDynamic ProgrammingEasyImplementation
Points:20
8 votes
Tags:
Real worldAlgorithmsDynamic ProgrammingIntroduction to Dynamic Programming 1
Points:20
58 votes
Tags:
AlgorithmsDynamic Programming