Maximum Subarray Sum
Find the largest sum of a non-empty contiguous subarray (Kadane's algorithm does it in one pass).
Input
, then integers.
Output
The maximum sum.
Constraints
,
Sample 1
Input
9 -2 1 -3 4 -1 2 1 -5 4
Output
6
Find the largest sum of a non-empty contiguous subarray (Kadane's algorithm does it in one pass).
, then integers.
The maximum sum.
,
Input
9 -2 1 -3 4 -1 2 1 -5 4
Output
6