// 果然越简单的题目,越是粗心大意!
if (str == null || str.length() == 0) { return -1; }
字符串(0<=字符串长度<=10000,全部由字母组成)
public class Solution { public int FirstNotRepeatingChar(String str) { if (str == null || str.length() == 0) { return -1; } int[] vis = new int[200]; for (int i = 0; i < str.length(); i++) { vis[str.charAt(i)]++; } for (int i = 0; i < str.length(); i++) { if (vis[str.charAt(i)] == 1) { return i; } } return -1; } }