From 59a8e5c89e69e913770763d4b2d0ba818cdef8bf Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:06:33 +0530 Subject: [PATCH] Create 1408. String Matching in an Array --- 1408. String Matching in an Array | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 1408. String Matching in an Array diff --git a/1408. String Matching in an Array b/1408. String Matching in an Array new file mode 100644 index 0000000..f25d062 --- /dev/null +++ b/1408. String Matching in an Array @@ -0,0 +1,17 @@ +class Solution { +public: + vector stringMatching(vector& words) { + vector 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; + } +};