Skip to content

Commit

Permalink
Create 1408. String Matching in an Array
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Jan 7, 2025
1 parent 58e95ca commit 59a8e5c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 1408. String Matching in an Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
vector<string> stringMatching(vector<string>& words) {
vector<string> result;

for (int i = 0; i < words.size(); i++) {
for (int j = 0; j < words.size(); j++) {
if (i != j && words[j].find(words[i]) != string::npos) {
result.push_back(words[i]);
break;
}
}
}

return result;
}
};

0 comments on commit 59a8e5c

Please sign in to comment.