題目鏈接:
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152
思路:記錄一下s2中出現過的字符即可。
代碼:
#include <bits/stdc++.h>
using namespace std;
map <char , int> mp;
int main() {
string s1 , s2;
ios::sync_with_stdio(0);
getline(cin , s1);
getline(cin , s2);
for(int i = 0 ; i < s2.length() ; i++) {
mp[s2[i]]++;
}
for(int i = 0 ; i < s1.length() ; i++) {
if(!mp.count(s1[i]))cout << s1[i];
}
cout << "\n";
return 0;
}