-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHJ23.CPP
38 lines (33 loc) · 915 Bytes
/
HJ23.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
#include<vector>
#include<unordered_map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string input;
while(cin>>input){
unordered_map<char,int> map;
for(auto i=input.begin();i!=input.end();i++){
if(map.find(*i)==map.end())
map.insert(make_pair(*i,1));
else map[*i]++;
}
int minQua = 21;
for(auto i=map.begin();i!=map.end();i++){
minQua = min(minQua,i->second);
}
vector<char> minList;
for(auto i=map.begin();i!=map.end();i++){
if(i->second==minQua) minList.push_back(i->first);
}
auto i=minList.begin();
while(i!=minList.end()){
while(input.find(*i)!=input.npos){
input.erase(input.find(*i),1);
}
i++;
}
cout<<input<<endl;
}
}