两全局数组

//Init module if you need
function Init()
{
    // write code here
    //全局声明
    arr=[]//存放只出现一次的字符
    res=''
    temp=[]//存放出现多处的字符
}
//Insert one char from stringstream
function Insert(ch)
{
    let newCh=ch
    if(ch!='/n'||ch!=null){
        this.res+=this.FirstAppearingOnce(ch)
    }else{ 
        console.log(this.res)
    } 
}
//return the first appearence once char in current stringstream
function FirstAppearingOnce(ch)
{
    // write code here

    if(this.arr.includes(ch)){
        this.temp.push(ch)
        this.arr.splice(this.arr.indexOf(ch),1);
    }else if(!(this.temp.includes(ch))){
        this.arr.push(ch);
    }
    return this.arr.length==0?'#':this.arr[0]
}