Track current sum. At each position:
- Add the current element to current sum.
- If current sum < , reset to (start fresh from next element).
- Update max sum seen. The core idea: a negative prefix never helps. If the sum so far is negative, throw it away and start fresh. Time: . Space: . Common bug: resetting before checking max, which loses single positive elements surrounded by negatives.