Maximum Subarray Sum (Kadane's Algorithm)

M · mediumPracticearrays

Find the sum of the contiguous subarray with the maximum sum.

Input
6
-2 1 -3 4 -1 2
Output
5
current_sum = max(arr[i], current_sum + arr[i]). max_sum = max(max_sum, current_sum).
← Matrix Reverse Diagonal ConsistencyMerge Two Arrays →
Report an issue with this question