Class Solution
java.lang.Object
g2101_2200.s2186_minimum_number_of_steps_to_make_two_strings_anagram_ii.Solution
2186 - Minimum Number of Steps to Make Two Strings Anagram II.<p>Medium</p>
<p>You are given two strings <code>s</code> and <code>t</code>. In one step, you can append <strong>any character</strong> to either <code>s</code> or <code>t</code>.</p>
<p>Return <em>the minimum number of steps to make</em> <code>s</code> <em>and</em> <code>t</code> <em><strong>anagrams</strong> of each other.</em></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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “<strong>lee</strong>tco<strong>de</strong>”, t = “co<strong>a</strong>t<strong>s</strong>”</p>
<p><strong>Output:</strong> 7</p>
<p><strong>Explanation:</strong></p>
<ul>
<li>
<p>In 2 steps, we can append the letters in “as” onto s = “leetcode”, forming s = “leetcode<strong>as</strong>”.</p>
</li>
<li>
<p>In 5 steps, we can append the letters in “leede” onto t = “coats”, forming t = “coats<strong>leede</strong>”.</p>
</li>
</ul>
<p>“leetcodeas” and “coatsleede” are now anagrams of each other.</p>
<p>We used a total of 2 + 5 = 7 steps.</p>
<p>It can be shown that there is no way to make them anagrams of each other with less than 7 steps.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “night”, t = “thing”</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> The given strings are already anagrams of each other. Thus, we do not need any further steps.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length, t.length <= 2 * 10<sup>5</sup></code></li>
<li><code>s</code> and <code>t</code> consist of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minSteps
-