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. def large_cont_sum(arr):
if len(arr)==0:
return 0
max_sum = current_sum = arr[0]
for num in arr[1:]:
current_sum = max(current_sum + num, num)
max_sum = max(current_sum, max_sum)
return max_sum