题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main(int argc, char* argv[]){
string str;
cin >> str;
unordered_map<char, int> dic;
for(char c : str){
++dic[c];
}
char c;
int min = INT_MAX;
for(auto p : dic){
if(p.second < min){
c = p.first;
min = p.second;
}
}
for(int i = 0; i < str.size(); ++i){
if(dic[str[i]] != min){
cout << str[i];
}
}
return 0;
}