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