forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.cpp
43 lines (34 loc) · 830 Bytes
/
Solution.cpp
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
42
43
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <jmorecfg.h>
#include <unordered_map>
using namespace std;
int countMatches(unordered_multimap<string, int> &strings, string query) {
return (int)(strings.count(query));
}
int main() {
int nrStrings;
int nrQueries;
unordered_multimap<string, int> strings;
vector<int> results;
cin >> nrStrings;
for (int i = 0; i < nrStrings; ++i) {
string tmpString;
cin >> tmpString;
strings.insert(make_pair(tmpString, 0));
}
cin >> nrQueries;
for (int j = 0; j < nrQueries; ++j) {
string tmpQuery;
cin >> tmpQuery;
results.push_back(countMatches(strings, tmpQuery));
}
for (int k = 0; k < results.size(); ++k) {
cout << results[k] << "\n";
}
return 0;
}