判断括号是否有效
var isValid = function(s) {
let map = new Map();
let map1 = new Map();
map.set("(",")");
map.set("[","]");
map.set("{","}");
map1.set(")","(");
map1.set("]","[");
map1.set("}","{");
let list = [];
for(let i=0;i<s.length;i++){
if(map.has(s[i])){
list.push(s[i])
}else{
if(map1.has(s[i])){
if(list.length==0)return false;
if(map.get(list[list.length-1])==s[i]){
list.pop();
}else{
return false;
}
}
}
}
if(list.length>0){
return false
}else{
return true
}
};