题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include <cctype>
#include <iostream>
#include <limits>
#include <sstream>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
int main() {
unordered_map<char, int> hash_map;
for (auto c='a'; c<='z'; c++) {
hash_map[c]= 0;
}
string s;
cin>>s;
for(auto c:s){
hash_map[c] +=1;
}
int min = numeric_limits<int>::max();
for(auto c:s){
if(hash_map[c] < min){
min = hash_map[c];
}
}
for (auto c:s) {
if(hash_map[c] == min){
hash_map[c]=0;
}
}
for (auto c:s) {
if (hash_map[c]!=0) {
cout<< c;
}
}
}
// 64 位输出请用 printf("%lld")

