1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 11:08:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/相似度为 K 的字符串 [k-similar-strings].html
2022-03-29 12:43:11 +08:00

31 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>字符串 <code>s1</code><code>s2</code><strong><code>k</code> 相似</strong> 的(对于某些非负整数 <code>k</code> ),如果我们可以交换 <code>s1</code> 中两个字母的位置正好 <code>k</code> 次,使结果字符串等于 <code>s2</code></p>
<p>给定两个字谜游戏 <code>s1</code><code>s2</code> ,返回 <code>s1</code><code>s2</code><strong><code>k</code> 相似&nbsp;</strong>的最小 <code>k</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s1 = "ab", s2 = "ba"
<strong>输出:</strong>1
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s1 = "abc", s2 = "bca"
<strong>输出:</strong>2
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s1.length &lt;= 20</code></li>
<li><code>s2.length == s1.length</code></li>
<li><code>s1</code>&nbsp;&nbsp;<code>s2</code>&nbsp;&nbsp;只包含集合&nbsp;<code>{'a', 'b', 'c', 'd', 'e', 'f'}</code>&nbsp;中的小写字母</li>
<li><code>s2</code><code>s1</code> 的一个字谜</li>
</ul>