---
# System prepended metadata

title: 2186. Minimum Number of Steps to Make Two Strings Anagram II
tags: [Leetcode, Medium]

---

# 2186. Minimum Number of Steps to Make Two Strings Anagram II
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii/description/
## Code
```java=
class Solution {
    public int minSteps(String s, String t) {
        int[] sCnt = new int[26];
        int[] tCnt = new int[26];
        for(int i=0; i<s.length(); i++){
            sCnt[s.charAt(i)-'a']++;
        }
        for(int i=0; i<t.length(); i++){
            tCnt[t.charAt(i)-'a']++;
        }
        int ans = 0;
        for(int i=0; i<26; i++){
            ans += Math.abs(sCnt[i]-tCnt[i]);
        }
        return ans;
    }
}
```