You are viewing a single comment's thread. Return to all comments →
Java:
I don't know what I'm doing wrong:
public static String balancedSums(List<Integer> arr) { Integer sumRight = arr.get(0); Integer sumLeft = 0; if(arr.size()>2){ for(int j=2;j<arr.size();j++){ sumLeft += arr.get(j); } if(sumLeft==0) return "YES"; for(int i=1;i<(arr.size()-1);i++){ if(sumRight==sumLeft){ return "YES"; } sumLeft-=arr.get(i+1); sumRight+=arr.get(i); } } else if (arr.size()==1){ return "YES"; } return "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Array
You are viewing a single comment's thread. Return to all comments →
Java:
I don't know what I'm doing wrong: