{"ScriptPreparationCode":"var groups = [[\u0027E\u0027, \u0027E_T\u0027], [\u0027T\u0027, \u0027T_T\u0027]];\r\n\r\nvar elements = [\r\n { t: \u0027E\u0027, cls: \u0027E\u0027 },\r\n { t: \u0027EU\u0027, cls: \u0027E_T\u0027 },\r\n { t: \u0027EC\u0027, cls: \u0027E_T\u0027 },\r\n { t: \u0027B\u0027, cls: \u0027B\u0027 },\r\n { t: \u0027T\u0027, cls: \u0027T\u0027 },\r\n { t: \u0027TU\u0027, cls: \u0027T_T\u0027 },\r\n];","TestCases":[{"Name":"A (2 cycles)","Code":"const temp = {};\r\n\r\nfor (const cGroup of groups) {\r\n const key = cGroup.join();\r\n \r\n for (const el of elements) {\r\n if (!cGroup.includes(el.cls)) {\r\n continue;\r\n }\r\n \r\n if (!temp[key]) {\r\n temp[key] = [el];\r\n } else {\r\n temp[key].push(el);\r\n }\r\n }\r\n}\r\n\r\nconst res = [];\r\n\r\nfor (const cGroup of Object.values(temp)) {\r\n res.push(cGroup);\r\n}","IsDeferred":false},{"Name":"B (1 cycle \u002B map)","Code":"const keyToIdx = {};\r\nconst res = [];\r\n\r\nfor (const cGroup of groups) {\r\n const key = cGroup.join();\r\n \r\n for (const el of elements) {\r\n if (!cGroup.includes(el.cls)) {\r\n continue;\r\n }\r\n \r\n const groupIdx = keyToIdx[key];\r\n\r\n if (groupIdx \u003E -1) {\r\n res[groupIdx].push(el);\r\n } else {\r\n keyToIdx[key] = (res.push([el]) - 1);\r\n }\r\n }\r\n}","IsDeferred":false}]}