Created
March 9, 2018 13:52
-
-
Save ApsarasX/d16f60e947b66f379dfaaaebdb0d0ce5 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 maxSubSequence(int arr[], int n) | |
{ | |
int sum = 0, maxSum = 0; | |
for (int i = 0; i < n; i++) | |
{ | |
sum += arr[i]; | |
if (sum > maxSum) | |
maxSum = sum; | |
else if (sum < 0) | |
{ | |
sum = 0; | |
} | |
} | |
return maxSum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment