You are viewing a single comment's thread. Return to all comments →
public static String balancedSums(List<Integer> arr) { // Write your code here long total = 0l; for(Integer i : arr){ total = total + i; } long leftSum =0L; long righSum = 0L; for(int i= 0; i < arr.size(); i++){ righSum = total - leftSum - arr.get(i); if(righSum == leftSum){ return "YES"; } leftSum = leftSum + arr.get(i); } 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 →