#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
class Solution
{
public:
bool canConstruct(string ransomNote, string magazine)
{
auto it = ransomNote.begin();
for (it; it != ransomNote.end(); it++)
{
if (magazine.find(*it) != string::npos)
{
magazine.erase(find(magazine.begin(),magazine.end(),*it));
continue;
}
else
return false;
}
if (it == ransomNote.end())
return true;
else
return false;
}
};
int main()
{
string ransomNote = "aab";
string magazine = "baa";
Solution a;
cout << a.canConstruct(ransomNote, magazine);
return 0;
}