Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
34 lines (29 loc) · 759 Bytes

File metadata and controls

34 lines (29 loc) · 759 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/* Here is given a phone book that consists of people's names and their phone number.
After that I will take some person's name as query.
For each query I print the phone number of that person. */
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh)
{
Scanner in = new Scanner(System.in);
int n=in.nextInt();
in.nextLine();
Map<String,Integer> m=new HashMap<String,Integer>();
for(int i=0;i<n;i++)
{
String name=in.nextLine();
int phone=in.nextInt();
m.put(name,phone);
in.nextLine();
}
while(in.hasNext())
{
String s=in.nextLine();
if(m.containsKey(s))
System.out.println(s+"="+m.get(s));
else
System.out.println("Not found");
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.