[编程题]第一个只出现一次的字符
第一个只出现一次的字符
http://www.nowcoder.com/questionTerminal/1c82e8cf713b4bbeb2a5b31cf5b0417c
O(n)极简内存版
public class Solution { public int FirstNotRepeatingChar(String str) { int[] counts = new int[58]; for(int i = 0; i < str.length(); i++) counts[str.charAt(i)-'A'] +=1; for(int i = 0; i < str.length(); i++) if(counts[str.charAt(i)-'A'] == 1) return i; return -1; } }