Appearance
s = "abaccdeff" // 返回 "b" s = "" // 返回 " "
/** * @param {string} s * @return {character} */ const firstUniqChar = function (s) { const map = {} for (c of s) { if (map[c]) { map[c]++ } else { map[c] = 1 } } for (c of s) { if (map[c] === 1) { return c } } return ' ' }
题链