题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
// HJ23 删除字符串中出现次数最少的字符.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
map<char, int>mm;
while (cin >> s)
{
for (int i = 0; i < s.size(); i++)
{
mm[s[i]] += 1;
}
int len = s.length();
for (auto c : mm)
{
len = min(c.second, len);
}
for (auto x : s)
{
if (mm[x] == len)continue;
cout << x;
}
cout << endl;
mm.clear();
}
return 0;
}