/**
* @param {string} s
* @return {boolean}
*/
const map = {
')': '(',
'}': '{',
']': '[',
};
let stack;
var isValid = function(s) {
stack = [];
for (let i = 0; i < s.length; i++) {
const curr = s[i];
if (curr === '(' || curr === '[' || curr === '{') {
stack.push(curr);
continue;
}
if (stack.length === 0 || stack.pop() !== map[curr]) {
return false;
}
}
return stack.length === 0;
};