Dsa
Prefix Sum
Hard
Balanced Subarray Count
Given an array of integers consisting of only -1 and 1, count how many subarrays have a sum of zero. Input starts with an integer N (size of the array) followed by N integers.
Example:
Input:
6
1 -1 1 -1 1 -1
Output:
9
Key concepts
prefix_sumbalance
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