{"ScriptPreparationCode":"var first = [4, 5, 6, 7, 8];\r\nvar second = [1, 2, 3, 4];\r\n\r\nvar firstSet = new Set(first)\r\nvar secondSet = new Set(second);","TestCases":[{"Name":"Custom Set intersection","Code":"function hasIntersection(set, iterable) {\r\n if (set.size \u003E 0) {\r\n for (const item of iterable) {\r\n if (set.has(item)) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction doSetsHaveIntersection(a, b) {\r\n if (a.size \u003E b.size) {\r\n return hasIntersection(a, b);\r\n } else {\r\n return hasIntersection(b, a);\r\n }\r\n}\r\n\r\ndoSetsHaveIntersection(secondSet, firstSet)","IsDeferred":false},{"Name":"Lodash intersection","Code":"_.intersection(second, first)","IsDeferred":false},{"Name":"custom Array intersection","Code":"function doArraysIntersect(\r\n firstArray,\r\n secondArray\r\n) {\r\n if (!firstArray || firstArray.length === 0 || !secondArray || secondArray.length === 0) {\r\n return false;\r\n }\r\n\r\n for (let ii = 0; ii \u003C firstArray.length; ii\u002B\u002B) {\r\n const element = firstArray[ii];\r\n if (secondArray.indexOf(element) \u003E -1) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n\r\ndoArraysIntersect(second, first)","IsDeferred":false}]}