题目:https://leetcode.com/problems/first-unique-character-in-a-string/
难度:Easy
int firstUniqChar(char* s) { int a[26][2]={0}; for(int i=0;i<strlen(s);i++){ a[s[i]-'a'][0]++; a[s[i]-'a'][1]=i; } int res= 100000; for(int i=0;i<26;i++){ if(a[i][0]==1 && a[i][1]<res){ res=a[i][1]; } } if(res == 100000)return -1; return res; }