#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
unordered_set<char> s1;
for(int i=n-1;i>=0;i--)
{
if(s1.find(s[i])==s1.end()) {
s1.insert(s[i]);
}
else if(s[i]==max(s[i],s[i+1])){
s1.insert(s[i]);
}
}
string ans;
for(auto it=s1.begin();it!=s1.end();it++){
ans+=*it;
}
cout<<ans<<endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: