Interview Query

Equal Binary Subarrays

Start Timer

0:00:00

Upvote
1
Downvote
Save question
Mark as completed
View comments (2)
Next question

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


Comments

Loading comments...