{"ScriptPreparationCode":"function getRandomInt(min, max) {\r\n min = Math.ceil(min);\r\n max = Math.floor(max);\r\n return Math.floor(Math.random() * (max - min)) \u002B min;\r\n}\r\n\r\nconst thousand = 1000;\r\nvar max = 10 * thousand;\r\n\r\nvar arr1 = [];\r\nvar arr2 = [];\r\nfor (var i = 0; i \u003C= max; i\u002B\u002B) {\r\n arr1.push(getRandomInt(0, max));\r\n arr2.push(getRandomInt(0, max));\r\n}\r\nconsole.log(arr1);\r\nconsole.log(arr2);","TestCases":[{"Name":"Double loop","Code":"function getArrayDiffs2(array = [], comparison = []) {\r\n const result = [];\r\n // ignore duplicates and look for matches\r\n new Set(array).forEach(a =\u003E {\r\n const match = comparison.find(b =\u003E _.isEqual(a, b));\r\n if (match) {\r\n result.push([\u0022UNCHANGED\u0022, a]);\r\n }\r\n else {\r\n result.push([\u0022NEW\u0022, a]);\r\n }\r\n });\r\n // ignore duplicates and look for matches\r\n new Set(comparison).forEach(a =\u003E {\r\n const match = array.find(b =\u003E _.isEqual(a, b));\r\n if (!match) {\r\n result.push([\u0022DELETED\u0022, a]);\r\n }\r\n });\r\n return result;\r\n}\r\n\r\ngetArrayDiffs2(arr1,arr2);","IsDeferred":false},{"Name":"Single loop","Code":"function getArrayDiffs1(array = [], comparison = []) {\r\n const result = [];\r\n const comparisonSet = new Set(comparison);\r\n const cArray = Array.from(comparisonSet);\r\n new Set(array).forEach(a =\u003E {\r\n const match = cArray.indexOf(b =\u003E _.isEqual(a, b));\r\n if (match \u003E 0) {\r\n result.push([\u0022UNCHANGED\u0022, a]);\r\n cArray.splice(match, 1);\r\n }\r\n else {\r\n result.push([\u0022NEW\u0022, a]);\r\n }\r\n });\r\n // ignore duplicates and look for matches\r\n cArray.forEach(a =\u003E {\r\n result.push([\u0022DELETED\u0022, a]);\r\n });\r\n return result;\r\n}\r\n\r\ngetArrayDiffs1(arr1,arr2);","IsDeferred":false},{"Name":"XOR","Code":"function getArrayDiffs3(array = [], comparison = []) {\r\n const UNCHANGED = _.intersectionWith(array, comparison, _.isEqual);\r\n const newArray = _.differenceWith(array,UNCHANGED, _.isEqual);\r\n const DELETED = _.differenceWith(comparison,UNCHANGED, _.isEqual);\r\n const result = [];\r\n UNCHANGED.forEach(a =\u003E {\r\n result.push([\u0022UNCHANGED\u0022, a]);\r\n });\r\n DELETED.forEach(a =\u003E {\r\n result.push([\u0022DELETED\u0022, a]);\r\n });\r\n newArray.forEach(a =\u003E {\r\n result.push([\u0022NEW\u0022, a]);\r\n });\r\n return result;\r\n}\r\n\r\ngetArrayDiffs3(arr1,arr2);","IsDeferred":false}]}