You are viewing a single comment's thread. Return to all comments →
For Java:
import java.util.*; import java.io.*; class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Map<String, Integer> myMap; myMap = new HashMap<>(); for(int i = 0; i < n; i++){ String name = in.next(); int phone = in.nextInt(); myMap.put(name, phone); } while(in.hasNext()){ String s = in.next(); Integer phone = myMap.get(s); if (phone == null){ System.out.println("Not found"); } else { System.out.println(s + "=" + phone); } } in.close(); } }
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 →
For Java: