Skip to content

Instantly share code, notes, and snippets.

@Cee
Created May 29, 2014 01:30
Show Gist options
  • Save Cee/e87581577080f9dff25c to your computer and use it in GitHub Desktop.
Save Cee/e87581577080f9dff25c to your computer and use it in GitHub Desktop.
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;
}
}
@Cee
Copy link
Author

Cee commented May 29, 2014

贪心贪心~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment