-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThirteen.java
More file actions
29 lines (25 loc) · 804 Bytes
/
Thirteen.java
File metadata and controls
29 lines (25 loc) · 804 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
package HackerRank;
import java.util.*;
import java.io.*;
class Thirteen {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.nextLine(); // consume the newline after int input
Map<String, Integer> phoneBook = new HashMap<>();
for (int i = 0; i < n; i++) {
String name = in.nextLine();
int phone = Integer.parseInt(in.nextLine());
phoneBook.put(name, phone);
}
while (in.hasNext()) {
String s = in.nextLine();
if (phoneBook.containsKey(s)) {
System.out.println(s + "=" + phoneBook.get(s));
} else {
System.out.println("Not found");
}
}
in.close();
}
}