You are viewing a single comment's thread. Return to all comments →
static String solve(int[] a){ int len =a.length; int j=len-1; int i=0, sum1=0, sum2=0; while(i<len && j>=0){ if(sum1==sum2 && ((i-j)==0)){ return "YES"; }else if(sum1<sum2){ sum1+=a[i++]; }else{ sum2+=a[j--]; } } return "NO"; }
Sherlock and Array
You are viewing a single comment's thread. Return to all comments →