// Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

// The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.

@@ -226,8 +226,645 @@
 re not.%0A
+%0A%0Avar valid = true,%0A        pair = %7B%0A            '(': ')',%0A            '%5B': '%5D',%0A            '%7B': '%7D'%0A        %7D,%0A        nowWaitingFor = %5B%5D;%0A%0A    for (var i = 0; i %3C s.length; i++) %7B%0A        var nowChar = s.charAt(i);%0A        if (nowChar.match(/%5B(%5C%5B%5C%7B%5D/)) %7B%0A            nowWaitingFor.unshift(pair%5BnowChar%5D);%0A        %7D else if (nowChar.match(/%5B)%5C%5D%5C%7D%5D/)) %7B%0A            if (nowWaitingFor%5B0%5D !== nowChar) %7B%0A                valid = false;%0A                break;%0A            %7D else %7B%0A                nowWaitingFor.splice(0, 1);%0A            %7D%0A        %7D%0A    %7D%0A    if (nowWaitingFor.length !== 0) %7B%0A        valid = false;%0A    %7D%0A    return valid;%0A

add solution