#include <unordered_map>
#include <unordered_set>
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param ransomNote string字符串
* @param magazine string字符串
* @return bool布尔型
*/
bool canConstruct(string ransomNote, string magazine) {
int s1 = ransomNote.size();
int count = 0;
unordered_map<char, int> ss;
for(auto c : magazine){
ss[c]++;
}
int i = 0;
while (s1) {
if(ss[ransomNote[i]]!=0){
count ++;
ss[ransomNote[i]]--;
}
i++;
s1--;
}
if(count == ransomNote.size()){
return true;
}else {
return false;
}
}
};