Skip to content

Commit

Permalink
Merge pull request #12 from 5AbhishekSaxena/5AbhishekSaxena-patch-11
Browse files Browse the repository at this point in the history
Create JavaMap.java
  • Loading branch information
5AbhishekSaxena authored Oct 19, 2018
2 parents eb1565e + cdb9739 commit e78e2e7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Hackerrank/JavaMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* https://www.hackerrank.com/challenges/phone-book/problem
**/

import java.util.*;
import java.io.*;

class JavaMap{
public static void main(String []argh)
{
Scanner in = new Scanner(System.in);
int n=in.nextInt();
in.nextLine();
HashMap<String,Integer> data = new HashMap<>();
for(int i=0;i<n;i++)
{
String name=in.nextLine();
int phone=in.nextInt();
in.nextLine();
data.put(name, phone);
}
while(in.hasNext())
{
String key=in.nextLine();
if (data.containsKey(key)){
System.out.println(key + "=" + data.get(key));
}else{
System.out.println("Not found");
}
}
}
}



0 comments on commit e78e2e7

Please sign in to comment.