import java.util.HashMap; public class Solution { public int FirstNotRepeatingChar(String str) {

    HashMap<Character,Boolean> hash = new HashMap<>();
    char[] ch = str.toCharArray();
    int size = ch.length;
    for(char c : ch){
        hash.put(c,!hash.containsKey(c));
    }
    
    int result = -1;
    for(int i = 0;i < size;i ++){
        if(hash.get(ch[i])) {
            result = i;
            break;
        }
    }
    return result;
}

}