var firstUniqChar = function(s) {
const map={}
for(let i=0; i<s.length; i++){
map[s[i]]= (map[s[i]]||0)+1;
}
// if want to return character Index;
for(let i=0; i<s.length; i++){
if(map[s[i]] === 1)
return i
}
// if you want to return character
// for (let val in map) {
// if (map[val] === 1) {
// return val;
// }
// }
return -1
};
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)