AcWing 1570. 坏掉的键盘
原题链接
简单
作者:
Laity_3
,
2021-08-20 22:04:34
,
所有人可见
,
阅读 221
#include <bits/stdc++.h>
using namespace std;
unordered_map<int,pair<char, bool> > m;
unordered_map<char, bool> p;
int main() {
string s1, s2;
cin >> s1 >> s2;
for (int i = 0; i < s1.size(); i++) {
s1[i] = toupper(s1[i]);
m[i] = { s1[i],false };
}
for (int i = 0; i < s2.size(); i++)
s2[i] = toupper(s2[i]);
for (int i = 0, j = 0; i < s1.size(), j < s2.size(); ) {
if (s1[i] != s2[j]) {
i++;
}
else {
m[i].second = true;
i++; j++;
}
}
for(int i=0;i<m.size();i++){
if (m[i].second == false&&!p[m[i].first]) {
printf("%c", m[i].first);
p[m[i].first] = true;
}
}
}