# To calculate the maximum sum of subarray ending at current element, say maxEnding, # we can use the maximum sum ending at the previous element. # So for any element, we have two choices: # Choice 1: ...
- Find the maximum sum of a contiguous subarray in a given array. - Add the current element to sum. - Update maxi if the current sum is greater than maxi. - If sum becomes negative, reset sum to 0.