Skip to content
C

Subarray with Equal 0s and 1s

Mediumjavapythonccppjavascript

Given a binary array containing only 0 and 1, find the length of the longest contiguous subarray with an equal number of zeros and ones.

Input Format

The first line contains an integer N. The second line contains N space-separated integers, each 0 or 1.

Output Format

Print the maximum length, or 0 if no such subarray exists.

Input (stdin)

Output

Run your code to see output here...