mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
41 lines
1.4 KiB
HTML
41 lines
1.4 KiB
HTML
<p>给定两个字符串 <code>a</code> 和 <code>b</code>,寻找重复叠加字符串 <code>a</code> 的最小次数,使得字符串 <code>b</code> 成为叠加后的字符串 <code>a</code> 的子串,如果不存在则返回 <code>-1</code>。</p>
|
||
|
||
<p><strong>注意:</strong>字符串 <code>"abc"</code> 重复叠加 0 次是 <code>""</code>,重复叠加 1 次是 <code>"abc"</code>,重复叠加 2 次是 <code>"abcabc"</code>。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>a = "abcd", b = "cdabcdab"
|
||
<strong>输出:</strong>3
|
||
<strong>解释:</strong>a 重复叠加三遍后为 "ab<strong>cdabcdab</strong>cd", 此时 b 是其子串。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>a = "a", b = "aa"
|
||
<strong>输出:</strong>2
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>a = "a", b = "a"
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p><strong>示例 4:</strong></p>
|
||
|
||
<pre><strong>输入:</strong>a = "abc", b = "wxyz"
|
||
<strong>输出:</strong>-1
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= a.length <= 10<sup>4</sup></code></li>
|
||
<li><code>1 <= b.length <= 10<sup>4</sup></code></li>
|
||
<li><code>a</code> 和 <code>b</code> 由小写英文字母组成</li>
|
||
</ul>
|