看图写话题,先统计出每个字符的出现次数,使用map
然后找到出现最少的字符的数量,然后将所有出现次数等于这个数量的字符删去即可
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5;
int __t = 1, n;
void solve() {
string s;
cin >> s;
map<char, int> mp;
for (char c : s)
mp[c]++;
int mi = 114514;
for (auto [x, y] : mp)
if (y < mi)
mi = y;
string result;
for (char c : s)
if (mp[c] != mi)
result += c;
cout << result << "\n";
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);
#endif
// cin >> __t;
while (__t--)
solve();
return 0;
}

京公网安备 11010502036488号