Optimal Algorithmic Approach
Kadane's: at each index decide whether to extend the current subarray or start a new one.
Core Invariants & Edge Cases
- currentMax = max(num, currentMax + num)
- globalMax tracks the best seen so far
- Handles all-negative arrays by returning the largest single element