Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Hackerrank/Hashmap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

//Complete this code or write your own from scratch
import java.util.*;
import java.io.*;

class Hashmap{
public static void main(String []argh)
{
Scanner x = new Scanner(System.in);
int n=x.nextInt();
x.nextLine();
Map<String, Integer> map = new HashMap<String, Integer>();
for(int i=0;i<n;i++)
{
String name = x.next();
int phone = x.nextInt();
x.nextLine();
map.put(name, phone);
}
while(x.hasNext())
{
String s=x.nextLine();
if (map.get(s) != null) {
System.out.println(s+"="+map.get(s));
} else {
System.out.println("Not found");
}
}
}
}