|
| 1 | +# [1967. Number of Strings That Appear as Substrings in Word](https://leetcode.cn/problems/number-of-strings-that-appear-as-substrings-in-word/description/) |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +<details> |
| 6 | +<summary>Topics</summary> |
| 7 | + |
| 8 | +* [`String`](https://leetcode.com/tag/string/) |
| 9 | + |
| 10 | +</details> |
| 11 | +<br /> |
| 12 | + |
| 13 | +Given an array of strings `patterns` and a string `word`, return *the **number** of strings in `patterns` that exist as a **substring** in `word`*. |
| 14 | + |
| 15 | +A **substring** is a contiguous sequence of characters within a string. |
| 16 | + |
| 17 | +**Example 1:** |
| 18 | + |
| 19 | + Input: patterns = ["a","abc","bc","d"], word = "abc" |
| 20 | + Output: 3 |
| 21 | + Explanation: |
| 22 | + - "a" appears as a substring in "abc". |
| 23 | + - "abc" appears as a substring in "abc". |
| 24 | + - "bc" appears as a substring in "abc". |
| 25 | + - "d" does not appear as a substring in "abc". |
| 26 | + 3 of the strings in patterns appear as a substring in word. |
| 27 | + |
| 28 | +**Example 2:** |
| 29 | + |
| 30 | + Input: patterns = ["a","b","c"], word = "aaaaabbbbb" |
| 31 | + Output: 2 |
| 32 | + Explanation: |
| 33 | + - "a" appears as a substring in "aaaaabbbbb". |
| 34 | + - "b" appears as a substring in "aaaaabbbbb". |
| 35 | + - "c" does not appear as a substring in "aaaaabbbbb". |
| 36 | + 2 of the strings in patterns appear as a substring in word. |
| 37 | + |
| 38 | +**Example 3:** |
| 39 | + |
| 40 | + Input: patterns = ["a","a","a"], word = "ab" |
| 41 | + Output: 3 |
| 42 | + Explanation: Each of the patterns appears as a substring in word "ab". |
| 43 | + |
| 44 | +**Constraints:** |
| 45 | + |
| 46 | + + `1 <= patterns.length <= 100` |
| 47 | + + `1 <= patterns[i].length <= 100` |
| 48 | + + `1 <= word.length <= 100` |
| 49 | + + `patterns[i]` and `word` consist of lowercase English letters. |
0 commit comments