Balanced Stretch — Solution & Editorial
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)
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)