-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.java
More file actions
35 lines (33 loc) · 924 Bytes
/
Map.java
File metadata and controls
35 lines (33 loc) · 924 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
31
32
33
34
35
//Complete this code or write your own from scratch
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argst)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); //denoting the number of queries..
Map<String,Integer> mp = new HashMap<String,Integer>(); //making map..
int i;
sc.nextLine();
for(i=0;i<n;i++)
{
String name = sc.nextLine(); //name
int ph = sc.nextInt(); //phone number
mp.put(name,ph);
sc.nextLine();
}
while(sc.hasNext()) //till the EOF
{
String q = sc.nextLine();
try
{
int p = mp.get(q);
System.out.println(q+"="+p);
}
catch (Exception e)
{
System.out.println("Not found");
}
}
}
}