Find the subarray with the largest sum, and return its sum.
Given an integer array `nums`, find the subarray with the largest sum, and return its sum.
Explanation: The subarray [4,-1,2,1] has the largest sum 6.
Invariant: maxSubarraySum ends at or before current index; negative prefixes are strictly discarded.
A negative prefix can never contribute to a maximal subsequent subarray sum.
Bottleneck: Linear scan.
Find the subarray with the largest sum, and return its sum.
Given an integer array `nums`, find the subarray with the largest sum, and return its sum.
Explanation: The subarray [4,-1,2,1] has the largest sum 6.
Invariant: maxSubarraySum ends at or before current index; negative prefixes are strictly discarded.
A negative prefix can never contribute to a maximal subsequent subarray sum.
Bottleneck: Linear scan.
Initialized Kadane's Algorithm. Array length = 9. Tracking contiguous running sum and global maximum.