- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
Latest commit
27 lines (22 loc) · 749 Bytes
/
Copy pathSolution.java
File metadata and controls
27 lines (22 loc) · 749 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
importjava.util.HashMap;
importjava.util.Map;
importjava.util.Scanner;
classSolution {
privatestaticfinalScannerin = newScanner(System.in);
privatestaticMap<String, Integer> phoneBook = newHashMap<>();
publicstaticvoidmain(String[] argh) {
intn = in.nextInt();
in.nextLine();
for (inti = 0; i < n; i++) {
Stringname = in.nextLine();
intphone = in.nextInt();
in.nextLine();
phoneBook.put(name, phone);
}
while (in.hasNext()) {
Strings = in.nextLine();
if (phoneBook.containsKey(s)) System.out.printf("%s=%d%n", s, phoneBook.get(s));
elseSystem.out.println("Not found");
}
}
}