1
class Solution {
2
public:
3
vector<string> stringMatching(vector<string> &words) {
4
vector<string> res; // output
5

6
for (int i = 0; i < words.size(); i++) {
7
for (int j = 0; j < words.size(); j++) {
8
if (i != j && words[j].find(words[i]) != -1) {
9
if (!count(res.begin(), res.end(),
10
words[i])) // if vector result does not include this
11
// string, push it to vector
12
res.push_back(words[i]);
13
else
14
continue; // if vector result includes this string, ignore
15
}
16
}
17
}
18

19
return res;
20
}
21
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0