383. Ransom Note

2018-04-11  本文已影响16人  安东可

383. Ransom Note

【思路】

    bool canConstruct(string ransomNote, string magazine) {
       
                
        unordered_map<char, int> map;
        for (int i = 0; i < magazine.size(); ++i)
            ++map[magazine[i]];
        for (int j = 0; j < ransomNote.size(); ++j)
            if (--map[ransomNote[j]] < 0)
                return false;
        return true; 
    }
上一篇 下一篇

猜你喜欢

热点阅读