Skip to content

Commit 98d8b53

Browse files
committed
Create 1408.数组中的字符串匹配.js
1 parent 8423603 commit 98d8b53

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

1408.数组中的字符串匹配.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string[]} words
3+
* @return {string[]}
4+
*/
5+
var stringMatching = function(words) {
6+
const result = [];
7+
for (let i = 0; i < words.length; i++) {
8+
for (let j = 0; j <words.length; j++) {
9+
if (i !== j && words[j].indexOf(words[i]) !== -1) {
10+
result.push(words[i]);
11+
break;
12+
}
13+
}
14+
}
15+
return result;
16+
};

0 commit comments

Comments
 (0)