#include <iostream> #include <unordered_set> using namespace std; int main() { string s; cin >> s; unordered_set<char> se; for (int i = s.size()-1; i != -1; i--) { if (se.find(s[i]) == se.end()) { cout << s[i]; se.emplace(s[i]); } } }
#include <iostream> #include <unordered_set> using namespace std; int main() { string s; cin >> s; unordered_set<char> se; for (int i = s.size()-1; i != -1; i--) { if (se.find(s[i]) == se.end()) { cout << s[i]; se.emplace(s[i]); } } }