mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
24 lines
952 B
HTML
24 lines
952 B
HTML
<p>Given two strings, <code>s1</code> and <code>s2</code>, write code to check if <code>s2</code> is a rotation of <code>s1</code> (e.g.,"waterbottle" is a rotation of"erbottlewat"). Can you use only one call to the method that checks if one word is a substring of another?</p>
|
|
|
|
|
|
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input: </strong>s1 = <span id="example-input-1-1">"waterbottle"</span>, s2 = <span id="example-input-1-2">"</span>erbottlewat<span>"</span>
|
|
|
|
<strong>Output: </strong><span id="example-output-1">True</span>
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input: </strong>s1 = "aa", s2 = "aba"
|
|
|
|
<strong>Output: </strong>False
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<p><strong>Note:</strong></p>
|
|
|
|
|
|
|
|
<ol>
|
|
|
|
<li><code><font face="monospace">0 <= s1.length, s2.length <= </font>100000</code></li>
|
|
|
|
</ol>
|
|
|