2022-03-27 18:27:43 +08:00
< p > Given an array of strings < code > patterns< / code > and a string < code > word< / code > , return < em > the < strong > number< / strong > of strings in < / em > < code > patterns< / code > < em > that exist as a < strong > substring< / strong > in < / em > < code > word< / code > .< / p >
< p > A < strong > substring< / strong > is a contiguous sequence of characters within a string.< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:27:43 +08:00
< pre >
< strong > Input:< / strong > patterns = [" a" ," abc" ," bc" ," d" ], word = " abc"
< strong > Output:< / strong > 3
< strong > Explanation:< / strong >
- " a" appears as a substring in " < u > a< / u > bc" .
- " abc" appears as a substring in " < u > abc< / u > " .
- " bc" appears as a substring in " a< u > bc< / u > " .
- " d" does not appear as a substring in " abc" .
3 of the strings in patterns appear as a substring in word.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:27:43 +08:00
< pre >
< strong > Input:< / strong > patterns = [" a" ," b" ," c" ], word = " aaaaabbbbb"
< strong > Output:< / strong > 2
< strong > Explanation:< / strong >
- " a" appears as a substring in " a< u > a< / u > aaabbbbb" .
- " b" appears as a substring in " aaaaabbbb< u > b< / u > " .
- " c" does not appear as a substring in " aaaaabbbbb" .
2 of the strings in patterns appear as a substring in word.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 18:27:43 +08:00
< pre >
< strong > Input:< / strong > patterns = [" a" ," a" ," a" ], word = " ab"
< strong > Output:< / strong > 3
< strong > Explanation:< / strong > Each of the patterns appears as a substring in word " < u > a< / u > b" .
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = patterns.length < = 100< / code > < / li >
< li > < code > 1 < = patterns[i].length < = 100< / code > < / li >
< li > < code > 1 < = word.length < = 100< / code > < / li >
< li > < code > patterns[i]< / code > and < code > word< / code > consist of lowercase English letters.< / li >
< / ul >