-
Notifications
You must be signed in to change notification settings - Fork 858
/
Day8DictionariesAndMaps.java
41 lines (36 loc) · 922 Bytes
/
Day8DictionariesAndMaps.java
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
36
37
38
39
40
41
/**
*
* Problem Statement-
* [Dictionaries and Maps](https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem)
*
*/
package com.javaaid.hackerrank.solutions.thirtydaysofcode;
import java.util.HashMap;
import java.util.Scanner;
/**
* @author Kanahaiya Gupta
*
*/
public class Day8DictionariesAndMaps {
public static void main(String[] argh) {
Scanner in = new Scanner(System.in);
HashMap<String, Integer> hmap = new HashMap<String, Integer>();
int n = in.nextInt();
for (int i = 0; i < n; i++) {
String name = in.next();
int phone = in.nextInt();
hmap.put(name, phone);
// Write code here
}
while (in.hasNext()) {
String s = in.next();
if (hmap.containsKey(s)) {
System.out.println(s + "=" + hmap.get(s));
} else {
System.out.println("Not found");
}
// Write code here
}
in.close();
}
}