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();Map<String,Integer>numberBook=newHashMap<>(n);for(inti=0;i<n;i++){Stringname=in.nextLine();intphone=in.nextInt();numberBook.put(name,phone);in.nextLine();}List<String>query=newArrayList<>();while(in.hasNext()){Strings=in.nextLine();query.add(s);}for(Stringq:query){if(numberBook.get(q)!=null)System.out.println(q+"="+numberBook.get(q));elseSystem.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 →