leetcode 383. Ransom Note

    bool canConstruct(string ransomNote, string magazine) {
        unordered_map<char, int> m;
        for (auto i : magazine)
            m[i]++;
        
        for (auto i : ransomNote) {
            if (m[i] == 0)
                return false;
            m[i]--;
        }
        return true;
    }

 

posted on 2018-02-09 18:36  willaty  阅读(70)  评论(0编辑  收藏  举报

导航