Ad
Code
Diff
  • def max_sequence(arr):
        # Code to find maximum sum of subarray
    	l_a = len(arr)
    	sum_b = sum(arr)
    	
    	for i in range(l_a):
    		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)
    • sum_b = sum(arr)
    • 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
    • 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)

29/2 - Added Tests

Tables
Data Structures
Code
Diff
  • def int_to_table(num):
        return list(range(0,num+1))
    • def int_to_table(num):
    • tab = []
    • for x in range(num + 1):
    • tab.append(x)
    • print(tab)
    • return tab
    • return list(range(0,num+1))