Created
May 29, 2014 01:30
-
-
Save Cee/e87581577080f9dff25c 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
public class Solution { | |
public int maxSubArray(int[] A) { | |
int sum = Integer.MIN_VALUE; | |
int ret = Integer.MIN_VALUE; | |
int length = A.length; | |
for(int i = 0; i < A.length; i++){ | |
if (sum < 0){ | |
sum = A[i]; | |
}else{ | |
sum += A[i]; | |
} | |
if (ret < sum) ret = sum; | |
} | |
return ret; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
贪心贪心~