Approach Summary
At each index, left_sum = prefix[i]; right_sum = total - prefix[i] - nums[i]. Return first index where they match.
How to Recognize This Pattern
- "Index where left sum equals right sum"
- Left sum grows, right sum shrinks — track both with total
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
Array Prefix Sum