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