Created
October 1, 2018 17:05
-
-
Save flymio/ab6e8ec5e6bea073fa826fd0344524d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Complete the birthdayCakeCandles function below. | |
function birthdayCakeCandles($ar) { | |
$maxHeight = max($ar); $cnt=0; | |
foreach($ar as $candle){ | |
if($candle == $maxHeight){ | |
$cnt++; | |
} | |
} | |
return $cnt; | |
} | |
$fptr = fopen(getenv("OUTPUT_PATH"), "w"); | |
$stdin = fopen("php://stdin", "r"); | |
fscanf($stdin, "%d\n", $ar_count); | |
fscanf($stdin, "%[^\n]", $ar_temp); | |
$ar = array_map('intval', preg_split('/ /', $ar_temp, -1, PREG_SPLIT_NO_EMPTY)); | |
$result = birthdayCakeCandles($ar); | |
fwrite($fptr, $result . "\n"); | |
fclose($stdin); | |
fclose($fptr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment