本文共 494 字,大约阅读时间需要 1 分钟。
class Solution { public: int FirstNotRepeatingChar(string str) { mapcount; char res; int len = str.length(); for(int i = 0 ; i < len ; i++){ count[str[i]]++; } for(int i = 0; i < len ;i++){ // count() 返回指定元素出现的次数 if(count[str[i]] == 1){ return i; } } return -1;// if(str.length()==0)// return -1;// for(int i=0;i
转载地址:http://xnklf.baihongyu.com/