mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
32 lines
1.2 KiB
HTML
32 lines
1.2 KiB
HTML
<p>给你一个字符串数组 <code>words</code> 和一个字符串 <code>pref</code> 。</p>
|
||
|
||
<p>返回 <code>words</code><em> </em>中以 <code>pref</code> 作为 <strong>前缀</strong> 的字符串的数目。</p>
|
||
|
||
<p>字符串 <code>s</code> 的 <strong>前缀</strong> 就是 <code>s</code> 的任一前导连续字符串。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>words = ["pay","<em><strong>at</strong></em>tention","practice","<em><strong>at</strong></em>tend"], <code>pref </code>= "at"
|
||
<strong>输出:</strong>2
|
||
<strong>解释:</strong>以 "at" 作为前缀的字符串有两个,分别是:"<em><strong>at</strong></em>tention" 和 "<em><strong>at</strong></em>tend" 。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>words = ["leetcode","win","loops","success"], <code>pref </code>= "code"
|
||
<strong>输出:</strong>0
|
||
<strong>解释:</strong>不存在以 "code" 作为前缀的字符串。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= words.length <= 100</code></li>
|
||
<li><code>1 <= words[i].length, pref.length <= 100</code></li>
|
||
<li><code>words[i]</code> 和 <code>pref</code> 由小写英文字母组成</li>
|
||
</ul>
|