Question bank › Two Pointers
Dsa Two Pointers Warm-up

Find the Longest Subarray with Equal 0s and 1s

Given a binary array (0s and 1s), find the length of the longest contiguous subarray that contains the same number of 0s and 1s. You need to return the length of this subarray. Example: Input: "001110000010" Output: 6 (The longest subarray is "111000" which has 3 1's and 3 0's)

Key concepts

two_pointerssubarraybalance

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.