#include <cstdio> #include <cstring> using namespace std; int main() { int chNumArr[256]; int firstIdxArr[256]; char ch, resCh; int idx = 0, resIdx = -1; memset(chNumArr, 0, sizeof(chNumArr)); memset(firstIdxArr, -1, sizeof(firstIdxArr)); while (EOF != scanf("%c", &ch)) { if(ch == '\n') { for(int i=0; i<256; i++){ if(chNumArr[i] != 1) { continue; } if(resIdx == -1) { resCh = i; resIdx = firstIdxArr[i]; } else if(firstIdxArr[i] < resIdx) { resCh = i; resIdx = firstIdxArr[i]; } } if(resIdx == -1) { printf("-1\n"); } else { printf("%c\n", resCh); } idx = 0; resIdx = -1; memset(chNumArr, 0, sizeof(chNumArr)); memset(firstIdxArr, -1, sizeof(firstIdxArr)); } else { chNumArr[ch]++; if(firstIdxArr[ch] == -1) { firstIdxArr[ch] = idx; } idx++; } } return 0; }