Skip to content

Instantly share code, notes, and snippets.

@Robbe7730
Created March 1, 2018 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robbe7730/c0ef470a24b64bd03a5e2ce85fe45bb1 to your computer and use it in GitHub Desktop.
Save Robbe7730/c0ef470a24b64bd03a5e2ce85fe45bb1 to your computer and use it in GitHub Desktop.
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