/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 *
 * @param s string字符串
 * @return bool布尔型
 */
function isValid(s) {
    // write code here
    let stack = [];
    for (let i = 0; i < s.length; i++) {
        if (s[i] == "}") {
            if (stack.length == 0 ||stack[stack.length-1] !== "{") return false;
            stack.pop();
        } else if (s[i] == "]") {
            if (stack.length == 0 ||stack[stack.length-1] !== "[") return false;
            stack.pop();
        } else if (s[i] == ")") {
            if (stack.length == 0 ||stack[stack.length-1] !== "(") return false;
            stack.pop();
        } else {
            console.log(stack);
            stack.push(s[i]);
        }
    }
    if (stack.length > 0) return false;
    return true;
}
module.exports = {
    isValid: isValid,
};