You are viewing a single comment's thread. Return to all comments →
javaScript solution tm
function balancedSums(arr) { if(arr.length === 1) return 'YES' let left = 0, el = arr[0], right = arr.slice(1).reduce((a,b) => a+b); if(left === right) return 'YES' for(let i=1; i<arr.length; i++){ left += el; el = arr[i]; right -= el; if(left === right) 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 →
javaScript solution tm