以下是他的代码
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string s,t;
queue<char> Q;
ll a = 0;
ll n = 0;
int main(){
cin >> s >> t;
for(ll i = 0;i < s.size();i++){
Q.push(s[i]);
}
while(!Q.empty()){
if(Q.front() != t[a]){
Q.pop();
n++;
}
else if(Q.front() == t[a]){
Q.pop();
if(a < t.size()) a++;
}
}
cout << abs(s.size() - n);
return 0;
}
为了证明我不是无中生有,这是我的代码
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<char,ll> book;
int main()
{
string a,b;
cin>>a>>b;
for (ll i = 0; i < a.size(); i ++) book[a[i]] ++;
ll c = 0;
for (ll i = 0; i < b.size(); i ++)
{
if (book.find(b[i]) != book.end() && book[b[i]] != 0)
{
c ++;
book[b[i]] --;
}
}
printf("%lld",c);
return 0;
}