mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 08:21:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,29 +1,44 @@
|
||||
<p>You are given a string <code>s</code> and an array of strings <code>words</code> of <strong>the same length</strong>. Return all starting indices of substring(s) in <code>s</code> that is a concatenation of each word in <code>words</code> <strong>exactly once</strong>, <strong>in any order</strong>, and <strong>without any intervening characters</strong>.</p>
|
||||
<p>You are given a string <code>s</code> and an array of strings <code>words</code>. All the strings of <code>words</code> are of <strong>the same length</strong>.</p>
|
||||
|
||||
<p>You can return the answer in <strong>any order</strong>.</p>
|
||||
<p>A <strong>concatenated substring</strong> in <code>s</code> is a substring that contains all the strings of any permutation of <code>words</code> concatenated.</p>
|
||||
|
||||
<ul>
|
||||
<li>For example, if <code>words = ["ab","cd","ef"]</code>, then <code>"abcdef"</code>, <code>"abefcd"</code>, <code>"cdabef"</code>, <code>"cdefab"</code>, <code>"efabcd"</code>, and <code>"efcdab"</code> are all concatenated strings. <code>"acdbef"</code> is not a concatenated substring because it is not the concatenation of any permutation of <code>words</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the starting indices of all the concatenated substrings in </em><code>s</code>. You can return the answer in <strong>any order</strong>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "barfoothefoobarman", words = ["foo","bar"]
|
||||
<strong>Output:</strong> [0,9]
|
||||
<strong>Explanation:</strong> Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.
|
||||
The output order does not matter, returning [9,0] is fine too.
|
||||
<strong>Explanation:</strong> Since words.length == 2 and words[i].length == 3, the concatenated substring has to be of length 6.
|
||||
The substring starting at 0 is "barfoo". It is the concatenation of ["bar","foo"] which is a permutation of words.
|
||||
The substring starting at 9 is "foobar". It is the concatenation of ["foo","bar"] which is a permutation of words.
|
||||
The output order does not matter. Returning [9,0] is fine too.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
|
||||
<strong>Output:</strong> []
|
||||
<strong>Explanation:</strong> Since words.length == 4 and words[i].length == 4, the concatenated substring has to be of length 16.
|
||||
There is no substring of length 16 in s that is equal to the concatenation of any permutation of words.
|
||||
We return an empty array.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
<p><strong class="example">Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]
|
||||
<strong>Output:</strong> [6,9,12]
|
||||
<strong>Explanation:</strong> Since words.length == 3 and words[i].length == 3, the concatenated substring has to be of length 9.
|
||||
The substring starting at 6 is "foobarthe". It is the concatenation of ["foo","bar","the"] which is a permutation of words.
|
||||
The substring starting at 9 is "barthefoo". It is the concatenation of ["bar","the","foo"] which is a permutation of words.
|
||||
The substring starting at 12 is "thefoobar". It is the concatenation of ["the","foo","bar"] which is a permutation of words.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
@@ -31,8 +46,7 @@ The output order does not matter, returning [9,0] is fine too.
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>s</code> consists of lower-case English letters.</li>
|
||||
<li><code>1 <= words.length <= 5000</code></li>
|
||||
<li><code>1 <= words[i].length <= 30</code></li>
|
||||
<li><code>words[i]</code> consists of lower-case English letters.</li>
|
||||
<li><code>s</code> and <code>words[i]</code> consist of lowercase English letters.</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user