-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionaries-maps.java
58 lines (53 loc) · 1.43 KB
/
dictionaries-maps.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.*;
import java.io.*;
class Solution {
public static void main(String []argh) {
Scanner in = new Scanner(System.in);
String s;
int N=in.nextInt();
Map<String,String> phoneBook = new HashMap<String,String>();
in.nextLine();
for(int i=0;i<N;i++)
{
String name=in.nextLine();
String phone=in.nextLine();
phoneBook.put(name,phone);
}
while(true) {
s=in.nextLine();
if(s==null) {
break;
} else if(phoneBook.get(s)!=null) {
String a=new StringBuilder(s).append("=").append(phoneBook.get(s)).toString();
System.out.println(a);
} else {
System.out.println("Not found");
}
}
}
}
/**/
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh)
{
Map<String, String> phoneBook = new HashMap<String, String>();
Scanner in = new Scanner(System.in);
int N = in.nextInt();
in.nextLine();
for (int i = 0; i < N; i++) {
String name = in.nextLine();
String phone = in.nextLine();
phoneBook.put(name, phone);
}
for (String s : phoneBook.keySet()) {
s = in.nextLine();
if (phoneBook.get(s) != null) {
System.out.println(s + "=" + phoneBook.get(s));
} else {
System.out.println("Not found");
}
}
}
}