-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathSolution.java
More file actions
30 lines (25 loc) · 760 Bytes
/
Solution.java
File metadata and controls
30 lines (25 loc) · 760 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
30
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Map<String, Integer> contacts = new HashMap<String, Integer>();
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine()); // number of contacts
for (int i = 0; i < n; i++) {
String name = sc.nextLine();
Integer number = Integer.parseInt(sc.nextLine());
contacts.put(name, number);
}
while (sc.hasNext()) {
String query = sc.nextLine();
if (contacts.containsKey(query)) {
System.out.println(query + "=" + contacts.get(query));
} else {
System.out.println("Not found");
}
}
}
}