function errorScore(syms) {
const stack = new Denque();
for (const sym of syms) {
if (sym == "{" || sym == "(" || sym == "[" || sym == "<") {
stack.push(sym);
} else {
const lastOpen = stack.pop();
if (sym == ")" && lastOpen != "(") {
return 3;
}
if (sym == "]" && lastOpen != "[") {
return 57;
}
if (sym == "}" && lastOpen != "{") {
return 1197;
}
if (sym == ">" && lastOpen != "<") {
return 25137;
}
}
}
return 0;
}