/**
  * 
  * @param s string字符串 
  * @return bool布尔型
  */
function isValid( s ) {
    // write code here
    let temp = [];
    let ret = null;
    s.split('').forEach(item => {
        if(item === '['){
            temp.push(item)
        }
        else if(item === '('){
            temp.push(item)
        }
        else if(item === '{'){
            temp.push(item)
        }

        else if(item === ']'){
            if(temp[temp.length-1] === '['){
                temp.pop()
                ret =  true
            }else{
                ret = false
            }
        }
        else if(item === ')'){
            if(temp[temp.length-1] === '('){
                temp.pop()
                ret = true
            }else{
                ret = false
            }
        }
        else if(item === '}'){

            if(temp[temp.length-1] === '{'){
                temp.pop()
                ret = true
            }else{
                ret = false
            }
        }
    });
    if(temp.length !== 0){
        ret = false;
    }
    console.log(temp)
    return ret
}
module.exports = {
    isValid : isValid
};