mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 10:51:42 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<p>有两个长度相同的字符串 <code>s1</code> 和 <code>s2</code>,且它们其中 <strong>只含有</strong> 字符 <code>"x"</code> 和 <code>"y"</code>,你需要通过「交换字符」的方式使这两个字符串相同。</p>
|
||||
<p>有两个长度相同的字符串 <code>s1</code> 和 <code>s2</code>,且它们其中 <strong>只含有</strong> 字符 <code>"x"</code> 和 <code>"y"</code>,你需要通过「交换字符」的方式使这两个字符串相同。</p>
|
||||
|
||||
<p>每次「交换字符」的时候,你都可以在两个字符串中各选一个字符进行交换。</p>
|
||||
|
||||
@@ -8,39 +8,37 @@
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
<p><strong class="example">示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>s1 = "xx", s2 = "yy"
|
||||
<pre>
|
||||
<strong>输入:</strong>s1 = "xx", s2 = "yy"
|
||||
<strong>输出:</strong>1
|
||||
<strong>解释:
|
||||
</strong>交换 s1[0] 和 s2[1],得到 s1 = "yx",s2 = "yx"。</pre>
|
||||
</strong>交换 s1[0] 和 s2[1],得到 s1 = "yx",s2 = "yx"。</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
<p><strong class="example">示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>s1 = "xy", s2 = "yx"
|
||||
<pre>
|
||||
<strong>输入:</strong>s1 = "xy", s2 = "yx"
|
||||
<strong>输出:</strong>2
|
||||
<strong>解释:
|
||||
</strong>交换 s1[0] 和 s2[0],得到 s1 = "yy",s2 = "xx" 。
|
||||
交换 s1[0] 和 s2[1],得到 s1 = "xy",s2 = "xy" 。
|
||||
注意,你不能交换 s1[0] 和 s1[1] 使得 s1 变成 "yx",因为我们只能交换属于两个不同字符串的字符。</pre>
|
||||
</strong>交换 s1[0] 和 s2[0],得到 s1 = "yy",s2 = "xx" 。
|
||||
交换 s1[0] 和 s2[1],得到 s1 = "xy",s2 = "xy" 。
|
||||
注意,你不能交换 s1[0] 和 s1[1] 使得 s1 变成 "yx",因为我们只能交换属于两个不同字符串的字符。</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
<p><strong class="example">示例 3:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>s1 = "xx", s2 = "xy"
|
||||
<pre>
|
||||
<strong>输入:</strong>s1 = "xx", s2 = "xy"
|
||||
<strong>输出:</strong>-1
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 4:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>s1 = "xxyyxyxyxx", s2 = "xyyxyxxxyx"
|
||||
<strong>输出:</strong>4
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s1.length, s2.length <= 1000</code></li>
|
||||
<li><code>s1, s2</code> 只包含 <code>'x'</code> 或 <code>'y'</code>。</li>
|
||||
<li><code>s1.length == s2.length</code></li>
|
||||
<li><code>s1, s2</code> 只包含 <code>'x'</code> 或 <code>'y'</code>。</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user