Problems > Balanced Stretch > Editorial

Balanced Stretch — Solution & Editorial

Back to the Problem

Map 0 → −1; a balanced subarray is one whose running sum repeats. Store the FIRST index of each running-sum value and stretch against it.

Complexity: O(N)