- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
Latest commit
32 lines (26 loc) · 936 Bytes
/
Copy pathSolution.java
File metadata and controls
32 lines (26 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//Complete this code or write your own from scratch
importjava.util.*;
importjava.io.*;
classSolution{
publicstaticvoidmain(String[] args) throwsIOException {
/* Save input as entries in a HashMap */
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
intn = Integer.parseInt(br.readLine());
HashMap<String, Integer> map = newHashMap();
while (n-- > 0) {
Stringname = br.readLine();
intphone = Integer.parseInt(br.readLine());
map.put(name, phone);
}
/* Read each query and check if its in our HashMap */
Strings;
while((s = br.readLine()) != null) {
if (map.containsKey(s)) {
System.out.println(s + "=" + map.get(s));
} else {
System.out.println("Not found");
}
}
br.close();
}
}