Simple Solution in Java Using Kadane's Algorithm

public class Solution {
public int maxSubArray(final int[] A) {
int meh=0;
int msf=Integer.MIN_VALUE;
for(int i=0;i<A.length;i++){
meh=meh+A[i];
if(meh<A[i]){
meh=A[i];
}
if(msf<meh){
msf=meh;
}
}
return msf;
}
}

1 Like

Can you please suggest to me a book(s) or a youtube playlist(s) or an
online course(s) where I can learn all such kinds of algorithms?

Click here to start solving coding interview questions