https://leetcode.com/problems/ransom-note/description/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public:
bool canConstruct(string ransomNote, string magazine) {
int count[26] = {0};
for(auto letter : magazine){
count[letter - 'a'] += 1;
}
for(auto letter : ransomNote){
if (!count[letter - 'a']){
return false;
}
count[letter - 'a'] -= 1;
}
return true;
}
};