← Discussions on Find the Balance Index
A agoud
12 Sep 2026, 14:31

Simple approach explained for beginners.

A single pass with a running value is enough here. Keep track of the best answer so far and update it as you scan, which gives O(n) time and O(1) extra space.

3 replies

sdeshpande 1 month ago

Same idea, but I used a deque. Works fine.

srinivas_18 1 month ago

Nice. Got asked a variant of this in an interview.

varunbanerjee 3 weeks, 6 days ago

Watch out for integer overflow in Java on the large test.

Sign in to reply.