-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay-7
28 lines (23 loc) · 780 Bytes
/
Day-7
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
import java.util.*;
import java.io.*;
class Solution {
public static void main(String[] argh) {
Map<String, Integer> phoneBook = new HashMap<String, Integer>();
Scanner in = new Scanner(System.in);
// Read the number of entries
int n = in.nextInt();
// Populate the phone book
for (int i = 0; i < n; i++) {
String name = in.next();
int phone = in.nextInt();
phoneBook.put(name, phone);
}
// Process queries
while (in.hasNext()) {
String s = in.next();
Integer phoneNumber = phoneBook.get(s);
System.out.println((phoneNumber != null) ? s + "=" + phoneNumber : "Not found");
}
in.close();
}
}