Skip to content

Instantly share code, notes, and snippets.

@nerohoop
Created July 22, 2017 08:49
Show Gist options
  • Save nerohoop/19965177c0b429982eec3a7c29b62bde to your computer and use it in GitHub Desktop.
Save nerohoop/19965177c0b429982eec3a7c29b62bde to your computer and use it in GitHub Desktop.
Initialize:
max_so_far = 0
max_ending_here = 0
Loop for each element of the array
(a) max_ending_here = max_ending_here + a[i]
(b) if(max_ending_here < 0)
max_ending_here = 0
(c) if(max_so_far < max_ending_here)
max_so_far = max_ending_here
return max_so_far
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment