class Solution {
public:
bool canConstruct(string ransomNote, string magazine) {
unordered_map<char, int> map;
for (int i = 0; i<magazine.length(); i++) {
map[magazine[i]]++;
}
for (int j = 0; j<ransomNote.length(); j++) {
if(--map[ransomNote[j]]<0) return 0;
}
return 1;
}
};
Ransom Note
Copyright © 2017 Powered by LZH, Theme used GitHub CSS.