1# Copyright (c) Microsoft Corporation and GitHub. All rights reserved. 2 3def subarray_min_max_sum(l): 4 # given an array of size n > 1 comute min and max of sums of all subarrays of size n-1 5 # if n <= 1 return None 6 # return a tuple (min_sum,max_sum) 7 8 complete_sum = sum(l) 9 min_sum = complete_sum - l[0] 10 max_sum = complete_sum - l[0] 11 for x in l[1:]: 12 temp_sum = complete_sum - x 13 min_sum = min(min_sum,temp_sum) 14 max_sum = max(max_sum,temp_sum) 15 return min_sum,max_sum 16 17 18