1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     int firstUniqChar(string s) 
12     {
13         vector<int> vi(128,0);
14         for(char c : s)
15             vi[c]++;
16         int len=s.length();
17         for(int i=0;i<len;i++)
18             if(vi[s[i]]==1)
19                 return i;
20         return -1;             
21     }
22 };

仍然是可以用map,也可以用vector,随意

posted on 2018-05-26 18:32  高数考了59  阅读(74)  评论(0)    收藏  举报