Minimum Number of Steps to Make Two Strings Anagram II

给两个字符串s和t, 能任意在后边添加字符, 求最少多少步后, 两个字符串能变成anagram.

这题就count下就行了…

class Solution {
    public int minSteps(String s, String t) {
        int res = 0;
        int[] count_s = new int[26];
        int[] count_t = new int[26];
        for(char c : s.toCharArray())
            count_s[c - 'a']++;
        for(char c : t.toCharArray())
            count_t[c - 'a']++;
        for(int i = 0; i < 26; i++){
            res += Math.abs(count_s[i] - count_t[i]);
        }
        return res;
    }
}