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)throwsIOException{BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));intn=Integer.valueOf(br.readLine());HashMap<String,Integer>map=newHashMap<>();while(n-->0){Stringname=br.readLine();intphone=Integer.valueOf(br.readLine());map.put(name,phone);}Strings;List<String>queryKeyValue=newArrayList<>();while((s=br.readLine())!=null){queryKeyValue.add(s);}for(Stringkey:queryKeyValue){if(map.containsKey(key)){System.out.println(key+"="+map.get(key));}else{System.out.println("Not found");}}br.close();}}
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 →
For Java 8