MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / maxSubArraySum

Function maxSubArraySum

Gfg/Python/Maxsubarray.py:2–26  ·  view source on GitHub ↗
(a, size)

Source from the content-addressed store, hash-verified

1#Program to find max subarray in python
2def maxSubArraySum(a, size):
3
4
5
6 max_so_far = 0
7
8 max_ending_here = 0
9
10
11
12 for i in range(0, size):
13
14 max_ending_here = max_ending_here + a[i]
15
16 if max_ending_here < 0:
17
18 max_ending_here = 0
19
20 elif (max_so_far < max_ending_here):
21
22 max_so_far = max_ending_here
23
24
25
26 return max_so_far
27
28a=[]
29n=int(input("size"))

Callers 1

Maxsubarray.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected