{"ScriptPreparationCode":"var books = Array.from({length: 1000}, (_, index) =\u003E ({id: index, mensionedIn: [{ids: [index, index \u002B 1, index \u002B 2, index \u002B 3]}]}))\r\nvar bookMap = new Map();\r\n\r\nbooks.forEach(book =\u003E {\r\n book.mensionedIn.forEach(mension =\u003E {\r\n mension.ids.forEach(id =\u003E {\r\n if (!bookMap.has(id)) {\r\n bookMap.set(id, []);\r\n }\r\n bookMap.get(id).push(book);\r\n });\r\n });\r\n});","TestCases":[{"Name":"filter -\u003E includes","Code":"var getBooksWithIndex_1 = (index) =\u003E {\r\n\treturn books.filter(book =\u003E book.mensionedIn.some(mensioned =\u003E mensioned.ids.includes(index)))\r\n}\r\ngetBooksWithIndex_1(4)\r\ngetBooksWithIndex_1(5)","IsDeferred":false},{"Name":"filter -\u003E Set.has()","Code":"const getBooksWithIndex_2 = (index) =\u003E {\r\n const bookIdSet = new Set([index])\r\n return books.filter(book =\u003E book.mensionedIn.some(mensioned =\u003E mensioned.ids.some(bookIndex =\u003E bookIdSet.has(bookIndex))))\r\n}\r\ngetBooksWithIndex_2(4)\r\ngetBooksWithIndex_2(5)","IsDeferred":false},{"Name":"Populate Map","Code":"const getBooksWithIndex_3 = (index)=\u003E {\r\n return bookMap.get(index);\r\n}\r\n\r\ngetBooksWithIndex_3(4)\r\ngetBooksWithIndex_3(5)","IsDeferred":false}]}