#include <iostream> #include <string> using namespace std; int g[1005]; int main() { string s; cin >> s; for (auto c : s) { g[c] ++; } int flag = 0; for (auto c : s) { if (g[c] == 1) { flag = 1; cout << c; break; } } if (!flag) cout << -1; }
#include <iostream> #include <string> using namespace std; int g[1005]; int main() { string s; cin >> s; for (auto c : s) { g[c] ++; } int flag = 0; for (auto c : s) { if (g[c] == 1) { flag = 1; cout << c; break; } } if (!flag) cout << -1; }