1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/作为子字符串出现在单词中的字符串数目 [number-of-strings-that-appear-as-substrings-in-word].html
2022-03-29 12:43:11 +08:00

50 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串数组 <code>patterns</code> 和一个字符串 <code>word</code> ,统计 <code>patterns</code> 中有多少个字符串是 <code>word</code> 的子字符串。返回字符串数目。</p>
<p><strong>子字符串</strong> 是字符串中的一个连续字符序列。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>patterns = ["a","abc","bc","d"], word = "abc"
<strong>输出:</strong>3
<strong>解释:</strong>
- "a" 是 "<em><strong>a</strong></em>bc" 的子字符串。
- "abc" 是 "<em><strong>abc</strong></em>" 的子字符串。
- "bc" 是 "a<em><strong>bc</strong></em>" 的子字符串。
- "d" 不是 "abc" 的子字符串。
patterns 中有 3 个字符串作为子字符串出现在 word 中。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>patterns = ["a","b","c"], word = "aaaaabbbbb"
<strong>输出:</strong>2
<strong>解释:</strong>
- "a" 是 "a<em><strong>a</strong></em>aaabbbbb" 的子字符串。
- "b" 是 "aaaaabbbb<em><strong>b</strong></em>" 的子字符串。
- "c" 不是 "aaaaabbbbb" 的字符串。
patterns 中有 2 个字符串作为子字符串出现在 word 中。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>patterns = ["a","a","a"], word = "ab"
<strong>输出:</strong>3
<strong>解释:</strong>patterns 中的每个字符串都作为子字符串出现在 word "<em><strong>a</strong></em>b" 中。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= patterns.length &lt;= 100</code></li>
<li><code>1 &lt;= patterns[i].length &lt;= 100</code></li>
<li><code>1 &lt;= word.length &lt;= 100</code></li>
<li><code>patterns[i]</code><code>word</code> 由小写英文字母组成</li>
</ul>