Java Map Hackkerank
//Complete this code or write your own from scratch
import java.util.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map.Entry;
class Solution{
public static void main(String arg[]) throws Exception{
InputStreamReader r=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(r);
int n=Integer.valueOf(br.readLine());
if(1<=n && n<=100000){
HashMap<String,String> aa=new HashMap<String,String>();
for(int i=0;i<n;i++){
String name=br.readLine();
String phone=br.readLine();
if(phone.length()==8 && phone.charAt(0)!='0'){
aa.put(name,phone);
}
}
while(n -->0){
String q;
while((q=br.readLine())!=null){
if(aa.containsKey(q)){
String k=q;
String val=aa.get(k);
System.out.println(k+"="+val);
}
else {
System.out.println("Not found");
}
}
}
br.close();
}
}
}
Thanks for Reading.
Comments
Post a Comment