Contiguous Array

Medium
ArrayHash TablePrefix SumMetaAmazon
Given a binary array, print the length of the longest contiguous subarray with the same number of 0s and 1s. Input format: - First line: n - Second line: n values, each 0 or 1

Constraints

1 <= n <= 10^5
nums[i] is 0 or 1

Sample tests

Sample 1

Sample 2

Sign in to submit