Skip to content

Commit 1bb94fd

Browse files
authored
Create 1408. String Matching in an Array (#684)
2 parents 58e95ca + 59a8e5c commit 1bb94fd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

1408. String Matching in an Array

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
vector<string> stringMatching(vector<string>& words) {
4+
vector<string> result;
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]) != string::npos) {
9+
result.push_back(words[i]);
10+
break;
11+
}
12+
}
13+
}
14+
15+
return result;
16+
}
17+
};

0 commit comments

Comments
 (0)