1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/制造字母异位词的最小步骤数 [minimum-number-of-steps-to-make-two-strings-anagram].html
2022-03-29 12:43:11 +08:00

51 lines
1.8 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>给你两个长度相等的字符串&nbsp;<code>s</code><code>t</code>。每一个步骤中,你可以选择将&nbsp;<code>t</code>&nbsp;中的 <strong>任一字符</strong> 替换为 <strong>另一个字符</strong></p>
<p>返回使&nbsp;<code>t</code>&nbsp;成为&nbsp;<code>s</code>&nbsp;的字母异位词的最小步骤数。</p>
<p><strong>字母异位词</strong> 指字母相同,但排列不同(也可能相同)的字符串。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输出:</strong>s = &quot;bab&quot;, t = &quot;aba&quot;
<strong>输出:</strong>1
<strong>提示:</strong>&#39;b&#39; 替换 t 中的第一个 &#39;a&#39;t = &quot;bba&quot; 是 s 的一个字母异位词。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输出:</strong>s = &quot;leetcode&quot;, t = &quot;practice&quot;
<strong>输出:</strong>5
<strong>提示:</strong>用合适的字符替换 t 中的 &#39;p&#39;, &#39;r&#39;, &#39;a&#39;, &#39;i&#39;&#39;c&#39;,使 t 变成 s 的字母异位词。
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输出:</strong>s = &quot;anagram&quot;, t = &quot;mangaar&quot;
<strong>输出:</strong>0
<strong>提示:</strong>&quot;anagram&quot;&quot;mangaar&quot; 本身就是一组字母异位词。
</pre>
<p><strong>示例 4</strong></p>
<pre><strong>输出:</strong>s = &quot;xxyyzz&quot;, t = &quot;xxyyzz&quot;
<strong>输出:</strong>0
</pre>
<p><strong>示例 5</strong></p>
<pre><strong>输出:</strong>s = &quot;friend&quot;, t = &quot;family&quot;
<strong>输出:</strong>4
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 50000</code></li>
<li><code>s.length == t.length</code></li>
<li><code>s</code><code>t</code>&nbsp;只包含小写英文字母</li>
</ul>