Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 286 Bytes

383. Ransom Note.md

File metadata and controls

14 lines (13 loc) · 286 Bytes
class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        vector<int> m(128, 0);
        for (char c : magazine) m[c]++;
        for (char c : ransomNote) {
            if (--m[c] < 0) return false;
        }
        return true;
    }
};