public class Solution {
    public int FirstNotRepeatingChar(String str) {
        int[] cns = new int[128];
        for(int i=0;i<str.length();i++){
            cns[str.charAt(i)]++;
        }
        for(int i=0;i<str.length();i++){
            if(cns[str.charAt(i)] == 1){
                return i;
            }
        }
        return -1;
    }
}