mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
40 lines
1.5 KiB
HTML
40 lines
1.5 KiB
HTML
<p>You are given two strings of the same length <code>s</code> and <code>t</code>. In one step you can choose <strong>any character</strong> of <code>t</code> and replace it with <strong>another character</strong>.</p>
|
|
|
|
<p>Return <em>the minimum number of steps</em> to make <code>t</code> an anagram of <code>s</code>.</p>
|
|
|
|
<p>An <strong>Anagram</strong> of a string is a string that contains the same characters with a different (or the same) ordering.</p>
|
|
|
|
<p> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "bab", t = "aba"
|
|
<strong>Output:</strong> 1
|
|
<strong>Explanation:</strong> Replace the first 'a' in t with b, t = "bba" which is anagram of s.
|
|
</pre>
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "leetcode", t = "practice"
|
|
<strong>Output:</strong> 5
|
|
<strong>Explanation:</strong> Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.
|
|
</pre>
|
|
|
|
<p><strong>Example 3:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "anagram", t = "mangaar"
|
|
<strong>Output:</strong> 0
|
|
<strong>Explanation:</strong> "anagram" and "mangaar" are anagrams.
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= s.length <= 5 * 10<sup>4</sup></code></li>
|
|
<li><code>s.length == t.length</code></li>
|
|
<li><code>s</code> and <code>t</code> consist of lowercase English letters only.</li>
|
|
</ul>
|