forked from SedaKunda/hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.java
More file actions
33 lines (31 loc) · 842 Bytes
/
Map.java
File metadata and controls
33 lines (31 loc) · 842 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
/*
You are given a phone book that consists of people's names and their phone number. After that you will be given some person's name as query. For each query, print the phone number of that person.
*/
import java.util.*;
import java.io.*;
class Map {
public static void main(String []argh)
{
Scanner in = new Scanner(System.in);
Map m = new HashMap();
int n=in.nextInt();
in.nextLine();
for(int i=0;i<n;i++)
{
String name=in.nextLine();
int phone=in.nextInt();
in.nextLine();
m.put(name,phone);
}
while(in.hasNext())
{
String s=in.nextLine();
if (m.containsKey(s)) {
System.out.println(s + "=" + m.get(s));
}
else {
System.out.println("Not found");
}
}
}
}