题解 | #第一个只出现一次的字符#
第一个只出现一次的字符
http://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c
class Solution { public: int FirstNotRepeatingChar(string str) {
if(str.empty()) return -1;
if(str.length() == 1) return 0;
for(int i=0;i<str.length();i++)
{
if(str.find_first_of(str[i]) == str.find_last_of(str[i]))
{
return i;
}
}
return -1;
}
};