https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=13&tqId=11187&tPage=2&rp=2&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking
题目描述
代码
class Solution { public: int FirstNotRepeatingChar(string str) { int tms[256]; // firstly, it's wrong without this sentence memset(tms, 0, sizeof(tms)); for (int i=0; i<str.size(); ++i) { int tmp = int(str[i]); tms[tmp] = tms[tmp]+ 1; } for (int i=0; i<str.size(); ++i) { int tmp = int(str[i]); if (tms[tmp] == 1) return i; } return -1; } };