Solution Review: Maximum Sum Subarray
This review discusses the solution to the "Maximum Sum Subarray" challenge in detail.
We'll cover the following...
We'll cover the following...
Solution (Kadane’s algorithm)
This algorithm takes a dynamic programming approach to solving the maximum subarray sum problem. Take a look at the algorithm.
The basic idea of “Kadane’s algorithm” is to scan the entire array. At each position, find the maximum sum of the subarray ending there. This is achieved by keeping a currMax for the current array index and a globalMax. The algorithm is as follows: