Example 1
Input
longest_equal_subarray([0, 1, 0, 1, 1, 0])
Output
6
The whole array has three 0s and three 1s, so length is 6.
Full lesson preview
Given a binary array, return the length of the longest contiguous subarray with equal numbers of 0s and 1s.
Problem statement
Task
Examples
Input
longest_equal_subarray([0, 1, 0, 1, 1, 0])
Output
6
The whole array has three 0s and three 1s, so length is 6.
Input format
Output format
Constraints
Samples
Input
[0,1,0,1,1,0]
Output
6
Full array balances to length 6