Python-algos: Largest Continuous Sum
Given an array of integers (positive and negative) find the largest continuous sum. An example of an array would be the following:
[7,2,-6,3,4,10,10,-10,-10] . The array’s maximum sum would be 30, summing everything until the last two
-10’s are not included in the sum.
max_sum = current_sum = arr
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(current_sum, max_sum)