You are viewing a single comment's thread. Return to all comments →
php
function balancedSums($arr) { $n = count($arr); $sum_total = array_sum($arr); $sum_left = 0; for($i = 0; $i < $n; $i++) { if($i == 0) { $sum_left = 0; } else { $sum_left += $arr[$i - 1]; } $sum_right = $sum_total - $sum_left - $arr[$i]; if($sum_left == $sum_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 →
php