1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/检查字符串是否为数组前缀 [check-if-string-is-a-prefix-of-array].html
2022-03-29 12:43:11 +08:00

36 lines
1.5 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>s</code> 和一个字符串数组 <code>words</code> ,请你判断 <code>s</code> 是否为 <code>words</code><strong>前缀字符串</strong></p>
<p>字符串 <code>s</code> 要成为 <code>words</code><strong>前缀字符串</strong> ,需要满足:<code>s</code> 可以由 <code>words</code> 中的前 <code>k</code><code>k</code><strong>正数</strong> )个字符串按顺序相连得到,且 <code>k</code> 不超过 <code>words.length</code></p>
<p>如果 <code>s</code><code>words</code><strong>前缀字符串</strong> ,返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "iloveleetcode", words = ["i","love","leetcode","apples"]
<strong>输出:</strong>true
<strong>解释:</strong>
s 可以由 "i"、"love" 和 "leetcode" 相连得到。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "iloveleetcode", words = ["apples","i","love","leetcode"]
<strong>输出:</strong>false
<strong>解释:</strong>
数组的前缀相连无法得到 s 。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 20</code></li>
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
<li><code>words[i]</code><code>s</code> 仅由小写英文字母组成</li>
</ul>