{"ScriptPreparationCode":"var noop = Function.prototype;\r\n\r\nvar isValidByMapSet = function (s) {\r\n let map = new Map();\r\n \r\n map.set(\u0027{\u0027, \u0027}\u0027);\r\n map.set(\u0027(\u0027, \u0027)\u0027);\r\n map.set(\u0027[\u0027, \u0027]\u0027);\r\n \r\n let b = [];\r\n for (let i = 0; i \u003C s.length; i\u002B\u002B) {\r\n if (map.has(s.charAt(i))) {\r\n b.push(s.charAt(i));\r\n }\r\n else {\r\n let pop = b.pop();\r\n if (map.get(pop) !== s.charAt(i)) {\r\n return false;\r\n }\r\n }\r\n }\r\n \r\n return b.length === 0;\r\n};\r\n\r\nvar isValidByHardCore = (function() {\r\n\r\n let level;\r\n let index;\r\n \r\n const array = new Array(1e4);\r\n \r\n// const CLOSED_SQUARE = 93; // \u0027]\u0027.charCodeAt(0);\r\n// const CLOSED_CURLY = 125; // \u0027}\u0027.charCodeAt(0);\r\n// const CLOSED_PARENTHESIS = 41; // \u0027)\u0027.charCodeAt(0);\r\n \r\n// const OPEN_SQUARE = 91; // \u0027[\u0027.charCodeAt(0);\r\n// const OPEN_CURLY = 123; // \u0027{\u0027.charCodeAt(0);\r\n// const OPEN_PARENTHESIS = 40; // \u0027(\u0027.charCodeAt(0);\r\n \r\n// const ID_SQUARE = {}; // just uniq object\r\n// const ID_CURLY = {}; // just uniq object\r\n// const ID_PARENTHESIS = {}; // just uniq object \r\n \r\n return (s) =\u003E {\r\n level = -1;\r\n index = s.length;\r\n while (index--) switch (s.charCodeAt(index)) {\r\n case 93:\r\n array[\u002B\u002Blevel] = 0;\r\n break;\r\n case 125:\r\n array[\u002B\u002Blevel] = 1;\r\n break;\r\n case 41:\r\n array[\u002B\u002Blevel] = 2;\r\n break;\r\n case 91:\r\n if (array[level--] !== 0) return false;\r\n break;\r\n case 123:\r\n if (array[level--] !== 1) return false;\r\n break;\r\n case 40:\r\n if (array[level--] !== 2) return false;\r\n break;\r\n \r\n }\r\n return level === -1;\r\n }\r\n})();","TestCases":[{"Name":"MapSet","Code":"if (isValidByMapSet(\u0027{}[ adas]( asdasd asdd sd) ad{ ada da{ asda {dsasadssdadsa sadas dasdas [](){{{{czxc xzcxz cz}}}[()]}da asd adsd asd [[[[[[[[[3434]]]]]]]]]asdsa da dasd asd (((3333)))asdsadasd{{{}}} asd asd asd asd}}}\u0027) == true) noop();\r\nif (isValidByMapSet(\u0027{}[ 1232 3123 312 12 213 12 123213 []{}{}{ asd asasd asda a}2d d adassasd dadsadasdas]()\u0027) == false) noop();\r\n","IsDeferred":false},{"Name":"HardCore","Code":"if (isValidByHardCore(\u0027{}[ adas]( asdasd asdd sd) ad{ ada da{ asda {dsasadssdadsa sadas dasdas [](){{{{czxc xzcxz cz}}}[()]}da asd adsd asd [[[[[[[[[3434]]]]]]]]]asdsa da dasd asd (((3333)))asdsadasd{{{}}} asd asd asd asd}}}\u0027) == true) noop();\r\nif (isValidByHardCore(\u0027{}[ 1232 3123 312 12 213 12 123213 []{}{}{ asd asasd asda a}2d d adassasd dadsadasdas]()\u0027) == false) noop();","IsDeferred":false}]}