题解 | 删除公共字符
删除公共字符
https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212
#include <iostream> #include <string> #include <unordered_set> using namespace std; int main() { string str1, str2; getline(cin, str1); getline(cin, str2); unordered_set<char> hash; for(auto c : str2) hash.insert(c); string ret; for(auto c : str1) if(!hash.count(c)) ret += c; cout << ret << endl; return 0; }