下面的代码:
用字母为对象的key来统计,遇到相同的字母对应的value加一,遍历输value为1的字符
//Init module if you need
let map = {}
function Init()
{
// write code here
map = {}
}
//Insert one char from stringstream
function Insert(ch)
{
// write code here
map[ch] = map[ch] ? map[ch]+1 : 1
}
//return the first appearence once char in current stringstream
function FirstAppearingOnce()
{
// write code here
for (const i in map) {
if (map[i] === 1) {
return i
}
}
return '#'
}