-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (25 loc) · 758 Bytes
/
main.cpp
File metadata and controls
29 lines (25 loc) · 758 Bytes
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
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
bool areSentencesSimilar(std::vector<std::string>& words1, std::vector<std::string>& words2, std::vector<std::pair<std::string, std::string>> pairs) {
if (words1.size() != words2.size()) {
return false;
}
std::unordered_map<std::string, std::unordered_set<std::string>> table;
for (const auto& p: pairs) {
table[p.first].insert(p.second);
table[p.second].insert(p.first);
}
for (int i = 0; i < words1.size(); i++) {
auto f = words1[i];
auto s = words2[i];
if (table[f].count(s) == 0 && f != s) {
return false;
}
}
return true;
}
int main() {
return 0;
}