Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- string s;
- map<char, int> mapa;
- bool comparar_letras(char a, char b) {
- return mapa[a] < mapa[b];
- }
- int main() {
- cin >> s;
- // s = "abaaac";
- // mapa[a] = 0
- // mapa[b] = 1
- // mapa[c] = 5
- // mapa[a] < mapa[b]
- for(int i = 0; i < s.size(); ++i) {
- if(mapa.find(s[i]) == mapa.end()) {
- mapa[s[i]] = i;
- }
- }
- // for(auto it : mapa) {
- // cout << it.first << ' ' << it.second << endl;
- // }
- sort(s.begin(), s.end(), comparar_letras);
- cout << s << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement