Skip to content

Commit 33d6ab1

Browse files
Create README - LeetHub
1 parent ef8a848 commit 33d6ab1

File tree

1 file changed

+34
-25
lines changed
  • 0030-substring-with-concatenation-of-all-words

1 file changed

+34
-25
lines changed

0030-substring-with-concatenation-of-all-words/README.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1-
<h2><a href="https://leetcode.com/problems/substring-with-concatenation-of-all-words/">30. Substring with Concatenation of All Words</a></h2><h3>Hard</h3><hr><div><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>
1+
<h2><a href="https://leetcode.com/problems/substring-with-concatenation-of-all-words">30. Substring with Concatenation of All Words</a></h2><h3>Hard</h3><hr><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>
22

3-
<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>
3+
<p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p>
44

55
<ul>
6-
<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>
6+
<li>For example, if <code>words = [&quot;ab&quot;,&quot;cd&quot;,&quot;ef&quot;]</code>, then <code>&quot;abcdef&quot;</code>, <code>&quot;abefcd&quot;</code>, <code>&quot;cdabef&quot;</code>, <code>&quot;cdefab&quot;</code>, <code>&quot;efabcd&quot;</code>, and <code>&quot;efcdab&quot;</code> are all concatenated strings. <code>&quot;acdbef&quot;</code> is not a concatenated string because it is not the concatenation of any permutation of <code>words</code>.</li>
77
</ul>
88

9-
<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>
9+
<p>Return an array of <em>the starting indices</em> of all the concatenated substrings in <code>s</code>. You can return the answer in <strong>any order</strong>.</p>
1010

1111
<p>&nbsp;</p>
1212
<p><strong class="example">Example 1:</strong></p>
1313

14-
<pre><strong>Input:</strong> s = "barfoothefoobarman", words = ["foo","bar"]
15-
<strong>Output:</strong> [0,9]
16-
<strong>Explanation:</strong> Since words.length == 2 and words[i].length == 3, the concatenated substring has to be of length 6.
17-
The substring starting at 0 is "barfoo". It is the concatenation of ["bar","foo"] which is a permutation of words.
18-
The substring starting at 9 is "foobar". It is the concatenation of ["foo","bar"] which is a permutation of words.
19-
The output order does not matter. Returning [9,0] is fine too.
20-
</pre>
14+
<div class="example-block">
15+
<p><strong>Input:</strong> <span class="example-io">s = &quot;barfoothefoobarman&quot;, words = [&quot;foo&quot;,&quot;bar&quot;]</span></p>
16+
17+
<p><strong>Output:</strong> <span class="example-io">[0,9]</span></p>
18+
19+
<p><strong>Explanation:</strong></p>
20+
21+
<p>The substring starting at 0 is <code>&quot;barfoo&quot;</code>. It is the concatenation of <code>[&quot;bar&quot;,&quot;foo&quot;]</code> which is a permutation of <code>words</code>.<br />
22+
The substring starting at 9 is <code>&quot;foobar&quot;</code>. It is the concatenation of <code>[&quot;foo&quot;,&quot;bar&quot;]</code> which is a permutation of <code>words</code>.</p>
23+
</div>
2124

2225
<p><strong class="example">Example 2:</strong></p>
2326

24-
<pre><strong>Input:</strong> s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
25-
<strong>Output:</strong> []
26-
<strong>Explanation:</strong> Since words.length == 4 and words[i].length == 4, the concatenated substring has to be of length 16.
27-
There is no substring of length 16 in s that is equal to the concatenation of any permutation of words.
28-
We return an empty array.
29-
</pre>
27+
<div class="example-block">
28+
<p><strong>Input:</strong> <span class="example-io">s = &quot;wordgoodgoodgoodbestword&quot;, words = [&quot;word&quot;,&quot;good&quot;,&quot;best&quot;,&quot;word&quot;]</span></p>
29+
30+
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
31+
32+
<p><strong>Explanation:</strong></p>
33+
34+
<p>There is no concatenated substring.</p>
35+
</div>
3036

3137
<p><strong class="example">Example 3:</strong></p>
3238

33-
<pre><strong>Input:</strong> s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]
34-
<strong>Output:</strong> [6,9,12]
35-
<strong>Explanation:</strong> Since words.length == 3 and words[i].length == 3, the concatenated substring has to be of length 9.
36-
The substring starting at 6 is "foobarthe". It is the concatenation of ["foo","bar","the"] which is a permutation of words.
37-
The substring starting at 9 is "barthefoo". It is the concatenation of ["bar","the","foo"] which is a permutation of words.
38-
The substring starting at 12 is "thefoobar". It is the concatenation of ["the","foo","bar"] which is a permutation of words.
39-
</pre>
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">s = &quot;barfoofoobarthefoobarman&quot;, words = [&quot;bar&quot;,&quot;foo&quot;,&quot;the&quot;]</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">[6,9,12]</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<p>The substring starting at 6 is <code>&quot;foobarthe&quot;</code>. It is the concatenation of <code>[&quot;foo&quot;,&quot;bar&quot;,&quot;the&quot;]</code>.<br />
47+
The substring starting at 9 is <code>&quot;barthefoo&quot;</code>. It is the concatenation of <code>[&quot;bar&quot;,&quot;the&quot;,&quot;foo&quot;]</code>.<br />
48+
The substring starting at 12 is <code>&quot;thefoobar&quot;</code>. It is the concatenation of <code>[&quot;the&quot;,&quot;foo&quot;,&quot;bar&quot;]</code>.</p>
49+
</div>
4050

4151
<p>&nbsp;</p>
4252
<p><strong>Constraints:</strong></p>
@@ -47,4 +57,3 @@ The substring starting at 12 is "thefoobar". It is the concatenation of ["the","
4757
<li><code>1 &lt;= words[i].length &lt;= 30</code></li>
4858
<li><code>s</code> and <code>words[i]</code> consist of lowercase English letters.</li>
4959
</ul>
50-
</div>

0 commit comments

Comments
 (0)