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