Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
pop the closing ones solution in Clear category for [old] Brackets by imtiaz.rahi
function brackets(expression) {
let stack = [];
const opening = ["(", "[", "{"], closing = [")", "]", "}"];
for (let ch of expression) {
if (opening.includes(ch))
stack.push(closing[opening.indexOf(ch)]);
else if (closing.includes(ch) && ch != stack.pop())
return false;
}
return stack.length == 0;
}
Oct. 25, 2019
Comments: