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)
import codewars_test as test
# TODO Write tests
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
test.assert_equals(1 + 1, 2)