We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
<?php$_fp=fopen("php://stdin","r");/* Enter your code here. Read input from STDIN. Print output to STDOUT */$phonebook=[];$n=intval(trim(fgets($_fp)));for($i=0;$i<$n;$i++){$array=explode(" ",trim(fgets($_fp)));$name=$array[0];$number=$array[1];$phonebook[$name]=$number;}while($query=trim(fgets($_fp))){if(array_key_exists($query,$phonebook)){echo"$query=$phonebook[$query]".PHP_EOL;}else{echo"Not found\n";}}?>
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
PHP