JAVA easy solution using KADANE ALGORITHM


#1

public int maxSubArray(final List A) {
int max_ending_here = 0;
int max_so_far=Integer.MIN_VALUE;
for(int i=0; i<A.size(); i++){
max_ending_here += A.get(i);
if(max_ending_here<A.get(i)){
max_ending_here = A.get(i);
}
if(max_so_far<max_ending_here){
max_so_far=max_ending_here;
}
}
return max_so_far;
}