```public class Solution {
public int FirstNotRepeatingChar(String str) {
if (str.length() == 0) {
return -1;
}
char[] chars = str.toCharArray();
// 遍历字符数组
for (char c:chars) {
// 出现一次的字符首尾一致
if (str.indexOf(c)==str.lastIndexOf(c)){
return str.indexOf(c);
}
}
return -1;
}
}
解题思路:
找出字符串仅出现一次的字符,即字符的首尾索引一致。