class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param ransomNote string字符串 
     * @param magazine string字符串 
     * @return bool布尔型
     */
    bool canConstruct(string ransomNote, string magazine) {
        // write code here
        unordered_map<char,int> un_ransomNote;
        unordered_map<char,int> un_magazine;
        for(auto c : ransomNote) {
            un_ransomNote[c]++;
        }
        for(auto c : magazine) {
            un_magazine[c]++;
        }
        for(auto it = un_ransomNote.begin(); it != un_ransomNote.end(); it++) {
            if(un_magazine[it->first] < it->second) {//magazine中某个字符的数量必须大于或等于ransomNote中该字符的数量才满足题意要求。如果it->first在magazine中不存在,那么un_magazine[it->first]就会等于0,还是符合逻辑,会拦下来的
                return false;
            }
        }
        return true;
    }
};