diff options
Diffstat (limited to 'progs/a922.py')
-rw-r--r-- | progs/a922.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/progs/a922.py b/progs/a922.py new file mode 100644 index 0000000..be47e86 --- /dev/null +++ b/progs/a922.py @@ -0,0 +1,10 @@ +def max_sub_array_sum(a, size):
+ max_so_far = 0
+ max_ending_here = 0
+ for i in range(0, size):
+ max_ending_here = max_ending_here + a[i]
+ if max_ending_here < 0:
+ max_ending_here = 0
+ elif (max_so_far < max_ending_here):
+ max_so_far = max_ending_here
+ return max_so_far
\ No newline at end of file |