2/29/2024
Maximum Subarray - Kadane's algorithm
This is the approach using Kadane's algorithm, in which we keep the running sum (maxEndingHere
), this variable will be the max sum of all subarray that ends at i. If that sum is negative, the subarray has no use for all array suffix it, so we reset maxEndingHer
to 0.