import java.util.LinkedHashMap;//保证插入顺序不乱
public class Solution {
    public int FirstNotRepeatingChar(String str) {
     LinkedHashMap<Character,Integer> map = new LinkedHashMap<Character,Integer>();
        for(int i = 0;i < str.length();i++){
            if(map.containsKey(str.charAt(i))){
                int count = map.get(str.charAt(i));
                map.put(str.charAt(i),++count);
            }else{
                map.put(str.charAt(i),1);
            }
        }
        
        for(int i = 0;i < str.length();i++){
            if(map.get(str.charAt(i)) == 1){
                return i;
            }
        }
        return -1;
    }
}