You are viewing a single comment's thread. Return to all comments →
Perl solution:
sub balancedSums { my $arr = shift; my $total_sum = sum(@$arr); my $left_sum = 0; foreach my $num (@$arr) { my $right_sum = $total_sum - $left_sum - $num; return "YES" if $left_sum == $right_sum; $left_sum += $num; } 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 →
Perl solution: