Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function equi ( $A ) {
- $count = count($A);
- $sum = array_sum($A) - $A[0];
- $i = 0;
- $sum_left = 0;
- while ($i < $count) {
- if ($sum_left == $sum)
- return $i;
- $sum_left += $A[$i];
- $sum -= $A[++$i];
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment