Equal Binary Subarrays
Start Timer
0:00:00
Given a binary array consisting of only 0s and 1s, create a Python function, equal_subarray
, that returns the maximum length of a contiguous subarray with an equal number of 0 and 1.
Example 1:
Input:
arr = [0, 1]
Output:
def equal_subarray(arr) -> 2
Example 2:
Input:
arr = [0, 1, 0, 1, 1]
Output:
def equal_subarray(arr) -> 4
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments