Skip to content

Instantly share code, notes, and snippets.

@yeco
Created February 23, 2010 19:00
Show Gist options
  • Select an option

  • Save yeco/312556 to your computer and use it in GitHub Desktop.

Select an option

Save yeco/312556 to your computer and use it in GitHub Desktop.
function equi ( $A ) {
$total = array_sum($A);
foreach($A as $key => $value){
if(($accumulated) == ($total - $accumulated - $value)){
return $key;
}
$accumulated += $value;
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment