Skip to content

Practice Minimum Number of Steps to Make Two Strings Anagram

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1347
LeetCode Problem

Minimum Number of Steps to Make Two Strings Anagram

Problem Statement

You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character. Return the minimum number of steps to make t an anagram of s. An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

Source: Minimum Number of Steps to Make Two Strings Anagram on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "bab", t = "aba"
Output
1

# Example 2

Input
s = "leetcode", t = "practice"
Output
5

# Example 3

Input
s = "anagram", t = "mangaar"
Output
0

Constraints

1 <= s.length <= 5 * 10^4
s.length == t.length
s and t consist of lowercase English letters only.

Related LeetCode Problems

Practice more problems similar to Minimum Number of Steps to Make Two Strings Anagram.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.