Skip to content

Commit 21bed45

Browse files
committed
Add solution #1408
1 parent 814e54c commit 21bed45

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
1374|[Generate a String With Characters That Have Odd Counts](./1374-generate-a-string-with-characters-that-have-odd-counts.js)|Easy|
148148
1380|[Lucky Numbers in a Matrix](./1380-lucky-numbers-in-a-matrix.js)|Easy|
149149
1389|[Create Target Array in the Given Order](./1389-create-target-array-in-the-given-order.js)|Easy|
150+
1408|[String Matching in an Array](./1408-string-matching-in-an-array.js)|Easy|
150151
1472|[Design Browser History](./1472-design-browser-history.js)|Medium|
151152
1598|[Crawler Log Folder](./1598-crawler-log-folder.js)|Easy|
152153
1880|[Check if Word Equals Summation of Two Words](./1880-check-if-word-equals-summation-of-two-words.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* 1408. String Matching in an Array
3+
* https://leetcode.com/problems/string-matching-in-an-array/
4+
* Difficulty: Easy
5+
*
6+
* Given an array of string words. Return all strings in words which is
7+
* substring of another word in any order.
8+
*
9+
* String words[i] is substring of words[j], if can be obtained removing
10+
* some characters to left and/or right side of words[j].
11+
*/
12+
13+
/**
14+
* @param {string[]} words
15+
* @return {string[]}
16+
*/
17+
var stringMatching = function(words) {
18+
return words.filter(s => words.some(word => word !== s && word.includes(s)));
19+
};

0 commit comments

Comments
 (0)