Created
July 22, 2017 08:48
-
-
Save nerohoop/0968d80c080fa8de4b28f618bbf47d44 to your computer and use it in GitHub Desktop.
This file contains 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
int max_so_far = INT_MIN; | |
int max_end_here = 0; | |
for(int i=0; i<size; i++) { | |
max_end_here += A[i]; | |
max_so_far = MAX(max_end_here, max_so_far); | |
max_end_here = MAX(0, max_end_here); | |
} | |
int maxNonCon = A[0]; | |
for(int i=1; i<size; i++) { | |
maxNonCon = MAX(maxNonCon, MAX(maxNonCon + A[i], A[i])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment