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();in.nextLine();HashMap<String,Integer>hashMap=newHashMap<>();for(inti=0;i<n;i++){Stringname=in.nextLine();intphone=in.nextInt();hashMap.put(name,phone);in.nextLine();}while(in.hasNext()){Strings=in.nextLine();if(hashMap.get(s)!=null){System.out.println(s+"="+hashMap.get(s));}else{System.out.println("Not found");}}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Map
You are viewing a single comment's thread. Return to all comments →