1347. Minimum Number of Steps to Make Two Strings Anagram Medium
1/**
2 * [1347] Minimum Number of Steps to Make Two Strings Anagram
3 *
4 * 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.
5 * Return the minimum number of steps to make t an anagram of s.
6 * An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.
7 *
8 * Example 1:
9 *
10 * Input: s = "bab", t = "aba"
11 * Output: 1
12 * Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.
13 *
14 * Example 2:
15 *
16 * Input: s = "leetcode", t = "practice"
17 * Output: 5
18 * Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.
19 *
20 * Example 3:
21 *
22 * Input: s = "anagram", t = "mangaar"
23 * Output: 0
24 * Explanation: "anagram" and "mangaar" are anagrams.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= s.length <= 5 * 10^4
30 * s.length == t.length
31 * s and t consist of lowercase English letters only.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/
37// discuss: https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn min_steps(s: String, t: String) -> i32 {
43 0
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1347() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.