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.
//Complete this code or write your own from scratchimportjava.util.*;importjava.io.*;classSolution{publicstaticvoidmain(String[]argh){Scannerin=newScanner(System.in);intn=in.nextInt();Map<String,Integer>myMap=newHashMap<String,Integer>();for(inti=0;i<n;i++){Stringname=in.next();intphone=in.nextInt();in.nextLine();myMap.put(name,phone);}while(in.hasNext()){Strings=in.next();if(myMap.get(s)==null)System.out.println("Not found");else{System.out.println(s+"="+myMap.get(s));}}in.close();}}
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 →
Thoughts?