leetcode: 383. Ransom Note
原题链接
class Solution {
public:
bool canConstruct(string ransomNote, string magazine) {
int mp[26] = {0};
for (char x : magazine)
mp[x - 'a']++;
for (char x : ransomNote) {
if (mp[x - 'a'] <= 0) return false;
mp[x - 'a']--;
}
return true;
}
};