Skip to content

Instantly share code, notes, and snippets.

@ojenikoh
Created September 9, 2014 00:04
Show Gist options
  • Save ojenikoh/60d56cf5e34a2211af9a to your computer and use it in GitHub Desktop.
Save ojenikoh/60d56cf5e34a2211af9a to your computer and use it in GitHub Desktop.
function solution($K, $A) {
$compliments = array();
array_walk_recursive($A, function($current, $key) use ($K, $A, &$compliments) {
foreach ($A as $oKey => $value) {
if ($current + $value == $K) {
$compliments[] = true;
}
}
});
return count($compliments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment