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);HashMap<String,Integer>map=newHashMap<>();intn=in.nextInt();for(inti=0;i<n;i++){Stringname=in.next();intphone=in.nextInt();// Write code heremap.put(name,phone);}while(in.hasNext()){Strings=in.next();// Write code hereif(map.containsKey(s)){System.out.println(s+"="+map.get(s));}else{System.out.println("Not found");}}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 →