Open fly0o0 opened 4 years ago
/**
* @param {string} s
* @return {character}
*/
var firstUniqChar = function(s) {
if (!s) return ' ';
let arr = s.split('')
let hashMap = {}
for (let v of arr) {
if (hashMap[v] == null) {
hashMap[v] = true
} else {
hashMap[v] = false
}
}
for (let v of arr) {
if (hashMap[v]) {
return v
}
}
return ' '
};