Created
March 1, 2018 11:33
-
-
Save Robbe7730/c0ef470a24b64bd03a5e2ce85fe45bb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def maxSubArraySum(a,size): | |
max_so_far =a[0] | |
curr_max = a[0] | |
start, stop = 0, 0 | |
for i in range(1,size): | |
curr_max = max(a[i], curr_max + a[i]) | |
max_so_far = max(max_so_far,curr_max) | |
if curr_max == a[i]: | |
start = i | |
elif max_so_far == curr_max: | |
stop = i | |
print(start, stop) | |
return max_so_far |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment