Problem
Ask
Submissions

Problem: Contiguous Array

Medium
30 min
Explore how to find the longest contiguous subarray where the count of 0s and 1s is balanced. Understand the problem using logical building blocks and implement an efficient hash map-based approach to solve it.

Statement

You are given a binary array nums containing only 0s0s and 1s1s. Your task is to find the maximum length of a contiguous subarray in which the number of 0s0s and 1s1s is exactly equal.

Return the length of the longest such subarray.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • nums[i] is either 00 or 11.

Problem
Ask
Submissions

Problem: Contiguous Array

Medium
30 min
Explore how to find the longest contiguous subarray where the count of 0s and 1s is balanced. Understand the problem using logical building blocks and implement an efficient hash map-based approach to solve it.

Statement

You are given a binary array nums containing only 0s0s and 1s1s. Your task is to find the maximum length of a contiguous subarray in which the number of 0s0s and 1s1s is exactly equal.

Return the length of the longest such subarray.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • nums[i] is either 00 or 11.