Skip to content

Commit eeeb99e

Browse files
Create maximum_subarray_sum.py
1 parent a71618f commit eeeb99e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def maxSubarraySum(arr):
2+
ans = arr[0]
3+
4+
for i in range(len(arr)):
5+
currentSum = 0
6+
7+
for j in range(i, len(arr)):
8+
currentSum = currentSum + arr[j]
9+
ans = max(ans, currentSum)
10+
11+
return ans
12+
13+
if __name__ == "__main__":
14+
arr = list(map(int, input().split(' ')))
15+
print(maxSubarraySum(arr))

0 commit comments

Comments
 (0)