> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/hashtable/1347.-minimum-number-of-steps-to-make-two-strings-anagram.md).

# 1347. Minimum Number of Steps to Make Two Strings Anagram

T: O(n)

S: O(1)

````java
```java
class Solution {
    public int minSteps(String s, String t) {
        int[] sMap = new int[26];
        int[] tMap = new int[26];
        for (int i = 0 ; i < s.length(); i++) {
            sMap[s.charAt(i) - 'a']++;
            tMap[t.charAt(i) - 'a']++;
        }
        int result = 0;
        for (int i = 0; i < 26; i++) {
            int diff = sMap[i] - tMap[i];
            if (diff > 0) {
                result += diff;
            }
        }
        return result;
    }
}

/**
2b1a
1b2a
b:2 1 1
a:1 2 -1

abb
aab


1. -1

l: 1 x
e: 3 1 2
t: 1 1
c: 1 2 -1
o:1. x
d:1  x
       
       i: 1
       a: 1 
       r: 1
       p: 1



 */
```
````
