You are viewing a single comment's thread. Return to all comments →
TypeScript
function balancedSums(arr: number[]): string { let totalSum = arr.reduce((acc, cur) => acc + cur); let leftSum = 0; for (let i = 0; i < arr.length; i++) { let rightSum = totalSum - leftSum - arr[i]; if (rightSum === leftSum) return 'YES'; leftSum += arr[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 →
TypeScript