You are viewing a single comment's thread. Return to all comments →
Super simple and self explainatory solution:
import java.io.*; import java.util.*; public class Solution { public static void main(String args[]) { Scanner in = new Scanner(System.in); int rows = in.nextInt(); in.nextLine(); Map<String, String> contacts = new HashMap<>(); for(int i = 0; i < rows; i++) { String name = in.nextLine(); String number = in.nextLine(); contacts.put(name, number); } while(in.hasNext()) { String name = in.nextLine(); if (contacts.get(name) == null) { System.out.println("Not found"); } else { System.out.println(String.format("%s=%s", name, contacts.get(name))); } } } }
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 →
Super simple and self explainatory solution: