Skip to content

Commit ac07a1f

Browse files
authored
Create Maximum Subarray Sum - 5 kyu.py
1 parent 82b3f89 commit ac07a1f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def max_sequence(arr):
2+
max_sum = 0
3+
current_sum = 0
4+
for num in arr:
5+
current_sum += num
6+
if current_sum < 0:
7+
current_sum = 0
8+
max_sum = max(max_sum, current_sum)
9+
return max_sum

0 commit comments

Comments
 (0)