#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
bool canConstruct(
string ransomNote,
string magazine)
{
vector<int> v(
26,
0);
for (
auto c : magazine)
v[c-
'a']++;
for (
auto c : ransomNote)
{
if (--v[c-
'a'] <
0)
return false;
}
return true;
}
};
void TEST()
{
string s1 =
"lan";
string s2 =
"xiaolan";
Solution sol;
cout << sol.canConstruct(s1, s2) << endl;
}
int main()
{
TEST();
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1300214.html