#include<iostream> #include<vector> #include<string> using namespace std; const int N = 1005; int h[26]; vector<char> v; int main() { string s; cin >> s; for (int i = 0; i < s.length(); i++) { h[s[i] - 'a']++; v.push_back(s[i]); } int flag = 0; for (auto it = v.begin(); it != v.end(); it++) { if (h[*it - 'a'] == 1) { cout << *it; flag = 1; break; } } if (!flag) cout << -1; return 0; }
用vector来存储顺序