-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Solution.java
30 lines (26 loc) · 863 Bytes
/
Solution.java
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
30
// github.com/RodneyShag
import java.util.Scanner;
import java.util.HashMap;
class Solution {
public static void main(String[] args) {
/* Save input as entries in a HashMap */
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
HashMap<String, Integer> map = new HashMap();
for (int i = 0; i < n; i++) {
String name = scan.next();
int phone = scan.nextInt();
map.put(name, phone);
}
/* Read each query and check if its in our HashMap */
while (scan.hasNext()) {
String str = scan.next();
if (map.containsKey(str)) {
System.out.println(str + "=" + map.get(str));
} else {
System.out.println("Not found");
}
}
scan.close();
}
}