class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param s string字符串 
     * @param c string字符串 
     * @return int整型
     */
    int isCongruent(string s, string c) {
        // write code here
        int result = 0;
        unordered_map<char, int> charCount_s;
        unordered_map<char,int> charCount_x;
        for(int i = 0; i < s.size(); i++) {
            charCount_s[s[i]]++;
        }
        for(int i = 0; i < c.size(); i++) {
            charCount_x[c[i]]++;
        }
        for(auto it = charCount_s.begin(); it != charCount_s.end();it++) {
            if(charCount_x[it->first] != it->second) {
                return -1;
            }
            result += it->second;//最后返回的值是s与x中出现相同的字符次数之和
        }
        return result;
    }
};