-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1408.cpp
More file actions
50 lines (40 loc) · 1.11 KB
/
1408.cpp
File metadata and controls
50 lines (40 loc) · 1.11 KB
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
44
45
46
47
#include<iostream>
#include<vector>
#include<string>
#include<unordered_set>
std::vector<std::string> stringMatching(std::vector<std::string>& words) {
std::vector<std::string> result;
std::unordered_set<std::string> seen;
for (int i = 0; i < words.size(); ++i) {
for (int j = 0; j < words.size(); ++j) {
if (i != j && words[i].find(words[j]) != std::string::npos) {
if (seen.find(words[j]) == seen.end()) {
result.push_back(words[j]);
seen.insert(words[j]);
}
}
}
}
return result;
}
int main() {
std::vector<std::string> vec2 = {
{ "blue" },
{ "blue" },
{ "green" },
{ "bl" },
{ "een" },
{ "en" },
{ "ee" },
{ "re" },
};
std::vector<std::string> vec = stringMatching(vec2);
for(std::string val : vec) {
std::cout << val << "\n";
}
/*std::cout << vec[0].size();*/
/*std::cout << vec[1].size();*/
/*std::cout << vec[2].size();*/
/*std::cout << vec[3].size();*/
std::cin.get();
}