Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Brackets by ZoltanOnody
"use strict";
const brackets = (expression) => {
let stack = [],
dict = {'(': ')', '[': ']', '{': '}' };
for(let ch of expression) {
if(!'()[]{}'.contains(ch))
continue;
if ('([{'.contains(ch))
stack.push(ch);
else if (ch !== dict[stack.pop()])
return false;
}
return stack.length === 0;
}
July 21, 2016
Comments: