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)/统计是给定字符串前缀的字符串数目 [count-prefixes-of-a-given-string].html

35 lines
1.4 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>给你一个字符串数组&nbsp;<code>words</code>&nbsp;和一个字符串&nbsp;<code>s</code>&nbsp;,其中&nbsp;<code>words[i]</code>&nbsp;<code>s</code>&nbsp;只包含 <strong>小写英文字母</strong>&nbsp;</p>
<p>请你返回 <code>words</code>&nbsp;中是字符串 <code>s</code>&nbsp;<strong>前缀&nbsp;</strong><strong>字符串数目</strong>&nbsp;</p>
<p>一个字符串的 <strong>前缀</strong>&nbsp;是出现在字符串开头的子字符串。<strong>子字符串</strong>&nbsp;是一个字符串中的连续一段字符序列。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>words = ["a","b","c","ab","bc","abc"], s = "abc"
<b>输出:</b>3
<strong>解释:</strong>
words 中是 s = "abc" 前缀的字符串为:
"a" "ab" 和 "abc" 。
所以 words 中是字符串 s 前缀的字符串数目为 3 。</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>words = ["a","a"], s = "aa"
<b>输出:</b>2
<strong>解释:
</strong>两个字符串都是 s 的前缀。
注意,相同的字符串可能在 words 中出现多次,它们应该被计数多次。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 1000</code></li>
<li><code>1 &lt;= words[i].length, s.length &lt;= 10</code></li>
<li><code>words[i]</code>&nbsp;<code>s</code>&nbsp;<strong></strong>&nbsp;包含小写英文字母。</li>
</ul>