{"ScriptPreparationCode":null,"TestCases":[{"Name":"Map","Code":"const createLists = (arr = []) =\u003E {\r\n const listMap = new Map();\r\n for (const val of arr) {\r\n if (!listMap.has(val)) {\r\n listMap.set(val, [val]);\r\n continue;\r\n } \r\n listMap.get(val).push(val);\r\n }\r\n return Array.from(listMap.values());\r\n};\r\n\r\nconsole.log(createLists([1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0]));","IsDeferred":false},{"Name":"forEach","Code":"function createLists(arr = []) {\r\n let authors = [];\r\n let list = [];\r\n\r\n arr.forEach(item =\u003E {\r\n let authorIndex = authors.includes(item) ? authors.indexOf(item) : (authors.push(item) - 1);\r\n list[authorIndex] = list[authorIndex] || [];\r\n list[authorIndex].push(item);\r\n });\r\n\r\n return list;\r\n}\r\n\r\nconsole.log(createLists([1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0]));","IsDeferred":false}]}