Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Brackets by mozurin
"use strict";
function brackets(expression)
{
const bracketMap = {'(': ')', '{': '}', '[': ']'};
const stack = [];
for (const c of expression.replace(/[^\(\{\[\]\}\)]/g, '')) {
if (c in bracketMap) {
stack.push(bracketMap[c]);
} else if (stack.pop() !== c) {
return false;
}
}
return stack.length === 0;
}
June 17, 2018
Comments: