mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 19:01:47 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
<p>给定一个字符串 <code>s</code><strong> </strong>和一些 <strong>长度相同</strong> 的单词 <code>words</code><strong> 。</strong>找出 <code>s</code><strong> </strong>中恰好可以由 <code>words</code><strong> </strong>中所有单词串联形成的子串的起始位置。</p>
|
||||
<p>给定一个字符串 <code>s</code><strong> </strong>和一个字符串数组 <code>words</code><strong>。</strong> <code>words</code> 中所有字符串 <strong>长度相同</strong>。</p>
|
||||
|
||||
<p>注意子串要与 <code>words</code><strong> </strong>中的单词完全匹配,<strong>中间不能有其他字符 </strong>,但不需要考虑 <code>words</code><strong> </strong>中单词串联的顺序。</p>
|
||||
<p> <code>s</code><strong> </strong>中的 <strong>串联子串</strong> 是指一个包含 <code>words</code> 中所有字符串以任意顺序排列连接起来的子串。</p>
|
||||
|
||||
<p> </p>
|
||||
<ul>
|
||||
<li>例如,如果 <code>words = ["ab","cd","ef"]</code>, 那么 <code>"abcdef"</code>, <code>"abefcd"</code>,<code>"cdabef"</code>, <code>"cdefab"</code>,<code>"efabcd"</code>, 和 <code>"efcdab"</code> 都是串联子串。 <code>"acdbef"</code> 不是串联子串,因为他不是任何 <code>words</code> 排列的连接。</li>
|
||||
</ul>
|
||||
|
||||
<p>返回所有串联子串在 <code>s</code><strong> </strong>中的开始索引。你可以以 <strong>任意顺序</strong> 返回答案。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "barfoothefoobarman", words = ["foo","bar"]
|
||||
<strong>输出:</strong><code>[0,9]</code>
|
||||
<strong>解释:</strong>
|
||||
从索引 0 和 9 开始的子串分别是 "barfoo" 和 "foobar" 。
|
||||
输出的顺序不重要, [9,0] 也是有效答案。
|
||||
<strong>解释:</strong>因为 words.length == 2 同时 words[i].length == 3,连接的子字符串的长度必须为 6。
|
||||
子串 "barfoo" 开始位置是 0。它是 words 中以 ["bar","foo"] 顺序排列的连接。
|
||||
子串 "foobar" 开始位置是 9。它是 words 中以 ["foo","bar"] 顺序排列的连接。
|
||||
输出顺序无关紧要。返回 [9,0] 也是可以的。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
@@ -19,6 +26,9 @@
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
|
||||
<code><strong>输出:</strong>[]</code>
|
||||
<strong>解释:</strong>因为<strong> </strong>words.length == 4 并且 words[i].length == 4,所以串联子串的长度必须为 16。
|
||||
s 中没有子串长度为 16 并且等于 words 的任何顺序排列的连接。
|
||||
所以我们返回一个空数组。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
@@ -26,16 +36,18 @@
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]
|
||||
<strong>输出:</strong>[6,9,12]
|
||||
</pre>
|
||||
<strong>解释:</strong>因为 words.length == 3 并且 words[i].length == 3,所以串联子串的长度必须为 9。
|
||||
子串 "foobarthe" 开始位置是 6。它是 words 中以 ["foo","bar","the"] 顺序排列的连接。
|
||||
子串 "barthefoo" 开始位置是 9。它是 words 中以 ["bar","the","foo"] 顺序排列的连接。
|
||||
子串 "thefoobar" 开始位置是 12。它是 words 中以 ["the","foo","bar"] 顺序排列的连接。</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>s</code> 由小写英文字母组成</li>
|
||||
<li><code>1 <= words.length <= 5000</code></li>
|
||||
<li><code>1 <= words[i].length <= 30</code></li>
|
||||
<li><code>words[i]</code> 由小写英文字母组成</li>
|
||||
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>1 <= words.length <= 5000</code></li>
|
||||
<li><code>1 <= words[i].length <= 30</code></li>
|
||||
<li><code>words[i]</code> 和 <code>s</code> 由小写英文字母组成</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user