1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 10:51:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

存量题库数据更新

This commit is contained in:
2023-12-09 18:42:21 +08:00
parent a788808cd7
commit c198538f10
10843 changed files with 288489 additions and 248355 deletions

View File

@@ -1,4 +1,4 @@
<p>有两个长度相同的字符串&nbsp;<code>s1</code>&nbsp;<code>s2</code>,且它们其中&nbsp;<strong>只含有</strong>&nbsp;字符&nbsp;<code>&quot;x&quot;</code>&nbsp;<code>&quot;y&quot;</code>,你需要通过「交换字符」的方式使这两个字符串相同。</p>
<p>有两个长度相同的字符串&nbsp;<code>s1</code>&nbsp;<code>s2</code>,且它们其中&nbsp;<strong>只含有</strong>&nbsp;字符&nbsp;<code>"x"</code>&nbsp;<code>"y"</code>,你需要通过「交换字符」的方式使这两个字符串相同。</p>
<p>每次「交换字符」的时候,你都可以在两个字符串中各选一个字符进行交换。</p>
@@ -8,39 +8,37 @@
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><strong class="example">示例 1</strong></p>
<pre><strong>输入:</strong>s1 = &quot;xx&quot;, s2 = &quot;yy&quot;
<pre>
<strong>输入:</strong>s1 = "xx", s2 = "yy"
<strong>输出:</strong>1
<strong>解释:
</strong>交换 s1[0] 和 s2[1],得到 s1 = &quot;yx&quot;s2 = &quot;yx&quot;</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 = &quot;xy&quot;, s2 = &quot;yx&quot;
<pre>
<strong>输入:</strong>s1 = "xy", s2 = "yx"
<strong>输出:</strong>2
<strong>解释:
</strong>交换 s1[0] 和 s2[0],得到 s1 = &quot;yy&quot;s2 = &quot;xx&quot;
交换 s1[0] 和 s2[1],得到 s1 = &quot;xy&quot;s2 = &quot;xy&quot;
注意,你不能交换 s1[0] 和 s1[1] 使得 s1 变成 &quot;yx&quot;,因为我们只能交换属于两个不同字符串的字符。</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 = &quot;xx&quot;, s2 = &quot;xy&quot;
<pre>
<strong>输入:</strong>s1 = "xx", s2 = "xy"
<strong>输出:</strong>-1
</pre>
<p><strong>示例 4</strong></p>
<pre><strong>输入:</strong>s1 = &quot;xxyyxyxyxx&quot;, s2 = &quot;xyyxyxxxyx&quot;
<strong>输出:</strong>4
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s1.length, s2.length &lt;= 1000</code></li>
<li><code>s1, s2</code>&nbsp;只包含&nbsp;<code>&#39;x&#39;</code>&nbsp;&nbsp;<code>&#39;y&#39;</code></li>
<li><code>s1.length == s2.length</code></li>
<li><code>s1, s2</code>&nbsp;只包含&nbsp;<code>'x'</code>&nbsp;&nbsp;<code>'y'</code></li>
</ul>