Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.
s = "leetcode"
return 0.
s = "loveleetcode"
return 2.
/**
* @param {string} s
* @return {number}
*/
var firstUniqChar = function(s) {
let mapIdx=new Map();
for(let i=0; i<s.length; i++){
let temp=mapIdx.get(s[i]);
if(temp!=null){
if(temp!=-1){
mapIdx.set(s[i],-1)
}
}else{
mapIdx.set(s[i],i);
}
}
let mapValues = map.values();
for(let val of mapValues){
if(val!=-1){
return val;
}
}
return -1;
};
~.~