Ad
Code
Diff
  • def max_sequence(arr):
        # Code to find maximum sum of subarray
    	l_a = len(arr)
    	counter = 0
    	for m in arr:
    		if m < 0:
    			counter = counter
    		else:
    			counter += 1
    	if counter == 0:
    		return(0)
    	for i in range(l_a):
    		if i == 0:
    			sum_b = sum(arr)
    		else:
    			for k in range(l_a-i+1):
    				sum_c = sum(arr[k:k+i])
    				if sum_c > sum_b: sum_b = sum_c
    	return(sum_b)
    
    • def max_sequence(arr):
    • # Code to find maximum sum of subarray
    • l_a = len(arr)
    • counter = 0
    • for m in arr:
    • if m < 0:
    • counter = counter
    • else:
    • counter += 1
    • if counter == 0:
    • return(0)
    • for i in range(l_a):
    • if i == 0:
    • sum_b = sum(arr)
    • else:
    • for k in range(l_a-i+1):
    • sum_c = sum(arr[k:k+i])
    • if sum_c > sum_b: sum_b = sum_c
    • return(sum_b)
def max_sequence(arr):
	l_a = len(arr)
	counter = 0
	for m in arr:
		if m < 0:
			counter = counter
		else:
			counter += 1
	if counter == 0:
		return(0)
	for i in range(l_a):
		if i == 0:
			sum_b = sum(arr)
		else:
			for k in range(l_a-i+1):
				sum_c = sum(arr[k:k+i])
				if sum_c > sum_b: sum_b = sum_c
	return(sum_b)