|
8 | 8 |
|
9 | 9 | <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>
|
10 | 10 |
|
11 |
| -<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> |
| 11 | +<p>A <strong>concatenated string</strong> is a string that exactly contains all the strings of any permutation of <code>words</code> concatenated.</p> |
12 | 12 |
|
13 | 13 | <ul>
|
14 |
| - <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> |
| 14 | + <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 string because it is not the concatenation of any permutation of <code>words</code>.</li> |
15 | 15 | </ul>
|
16 | 16 |
|
17 |
| -<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> |
| 17 | +<p>Return an array of <em>the starting indices</em> of all the concatenated substrings in<em> </em><code>s</code>. You can return the answer in <strong>any order</strong>.</p> |
18 | 18 |
|
19 | 19 | <p> </p>
|
20 | 20 | <p><strong class="example">Example 1:</strong></p>
|
21 | 21 |
|
22 |
| -<pre> |
23 |
| -<strong>Input:</strong> s = "barfoothefoobarman", words = ["foo","bar"] |
24 |
| -<strong>Output:</strong> [0,9] |
25 |
| -<strong>Explanation:</strong> Since words.length == 2 and words[i].length == 3, the concatenated substring has to be of length 6. |
26 |
| -The substring starting at 0 is "barfoo". It is the concatenation of ["bar","foo"] which is a permutation of words. |
27 |
| -The substring starting at 9 is "foobar". It is the concatenation of ["foo","bar"] which is a permutation of words. |
28 |
| -The output order does not matter. Returning [9,0] is fine too. |
29 |
| -</pre> |
| 22 | +<div class="example-block"> |
| 23 | +<p><strong>Input:</strong> <span class="example-io">s = "barfoothefoobarman", words = ["foo","bar"]</span></p> |
| 24 | + |
| 25 | +<p><strong>Output:</strong> <span class="example-io">[0,9]</span></p> |
| 26 | + |
| 27 | +<p><strong>Explanation:</strong></p> |
| 28 | + |
| 29 | +<p>The substring starting at 0 is <code>"barfoo"</code>. It is the concatenation of <code>["bar","foo"]</code> which is a permutation of <code>words</code>.<br /> |
| 30 | +The substring starting at 9 is <code>"foobar"</code>. It is the concatenation of <code>["foo","bar"]</code> which is a permutation of <code>words</code>.<br /> |
| 31 | +The output order does not matter. Returning <code>[9,0]</code> is fine too.</p> |
| 32 | +</div> |
30 | 33 |
|
31 | 34 | <p><strong class="example">Example 2:</strong></p>
|
32 | 35 |
|
33 |
| -<pre> |
34 |
| -<strong>Input:</strong> s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"] |
35 |
| -<strong>Output:</strong> [] |
36 |
| -<strong>Explanation:</strong> Since words.length == 4 and words[i].length == 4, the concatenated substring has to be of length 16. |
37 |
| -There is no substring of length 16 in s that is equal to the concatenation of any permutation of words. |
38 |
| -We return an empty array. |
39 |
| -</pre> |
| 36 | +<div class="example-block"> |
| 37 | +<p><strong>Input:</strong> <span class="example-io">s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]</span></p> |
| 38 | + |
| 39 | +<p><strong>Output:</strong> <span class="example-io">[]</span></p> |
| 40 | + |
| 41 | +<p><strong>Explanation:</strong></p> |
| 42 | + |
| 43 | +<p>There is no concatenated substring.</p> |
| 44 | +</div> |
40 | 45 |
|
41 | 46 | <p><strong class="example">Example 3:</strong></p>
|
42 | 47 |
|
43 |
| -<pre> |
44 |
| -<strong>Input:</strong> s = "barfoofoobarthefoobarman", words = ["bar","foo","the"] |
45 |
| -<strong>Output:</strong> [6,9,12] |
46 |
| -<strong>Explanation:</strong> Since words.length == 3 and words[i].length == 3, the concatenated substring has to be of length 9. |
47 |
| -The substring starting at 6 is "foobarthe". It is the concatenation of ["foo","bar","the"] which is a permutation of words. |
48 |
| -The substring starting at 9 is "barthefoo". It is the concatenation of ["bar","the","foo"] which is a permutation of words. |
49 |
| -The substring starting at 12 is "thefoobar". It is the concatenation of ["the","foo","bar"] which is a permutation of words. |
50 |
| -</pre> |
| 48 | +<div class="example-block"> |
| 49 | +<p><strong>Input:</strong> <span class="example-io">s = "barfoofoobarthefoobarman", words = ["bar","foo","the"]</span></p> |
| 50 | + |
| 51 | +<p><strong>Output:</strong> <span class="example-io">[6,9,12]</span></p> |
| 52 | + |
| 53 | +<p><strong>Explanation:</strong></p> |
| 54 | + |
| 55 | +<p>The substring starting at 6 is <code>"foobarthe"</code>. It is the concatenation of <code>["foo","bar","the"]</code>.<br /> |
| 56 | +The substring starting at 9 is <code>"barthefoo"</code>. It is the concatenation of <code>["bar","the","foo"]</code>.<br /> |
| 57 | +The substring starting at 12 is <code>"thefoobar"</code>. It is the concatenation of <code>["the","foo","bar"]</code>.</p> |
| 58 | +</div> |
51 | 59 |
|
52 | 60 | <p> </p>
|
53 | 61 | <p><strong>Constraints:</strong></p>
|
|
0 commit comments