387. 字符串中的第一个唯一字符
1 class Solution 2 { 3 public: 4 int firstUniqChar(string s) 5 { 6 unordered_map<char,int> hash; 7 for(auto a : s) hash[a] ++; 8 for(int i = 0;i < s.size();i ++) 9 { 10 if(hash[s[i]] == 1) return i; 11 } 12 return -1; 13 } 14 };
Mamba never out

浙公网安备 33010602011771号