JavaScript || O(n log n)
Intuition\n Describe your first thoughts on how to solve this problem. \nAfter sorting nums1 and nums2, one of the differences between nums2[0] and nums1[0], nu
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAfter sorting **nums1** and **nums2**, one of the differences between **nums2[0]** and **nums1[0]**, **nums1[1]**, **nums1[2]** must be the correct answer. This is because there are only two wrong elements in **nums1**.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing the three possible differences from **nums2[0]** - **nums1[0]**, **nums2[0]** - **nums1[1]**, **nums2[0]** - **nums1[2]**, find out how many pairs does not match the difference. Then, return the difference with the lowest amount of non-matching pairs.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n log n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar minimumAddedInteger = function (nums1, nums2) {\n    nums1.sort((a, b) => a - b);\n    nums2.sort((a, b) => a - b);\n    let ret = 9999999;\n    const first_possible = nums2[0] - nums1[0];\n    const second_possible = nums2[0] - nums1[1];\n    const third_possible = nums2[0] - nums1[2];\n    // first\n    let k = 0;\n    let counter = 0;\n    for (let i = 0; i < nums1.length; i++) {\n        if (k === nums2.length) {\n            break;\n        }\n        const cur = nums1[i];\n        const cur_k = nums2[k];\n        if (cur_k - cur !== first_possible) {\n            counter++;\n            continue;\n        }\n        k++;\n    }\n    if (counter <= 2) {\n        ret = Math.min(ret, first_possible);\n    }\n    // second\n    k = 0;\n    counter = 1;\n    for (let i = 1; i < nums1.length; i++) {\n        if (k === nums2.length) {\n            break;\n        }\n        const cur = nums1[i];\n        const cur_k = nums2[k];\n        if (cur_k - cur !== second_possible) {\n            counter++;\n            continue;\n        }\n        k++;\n    }\n    if (counter <= 2) {\n        ret = Math.min(ret, second_possible);\n    }\n    // third\n    k = 0;\n    counter = 2;\n    for (let i = 2; i < nums1.length; i++) {\n        if (k === nums2.length) {\n            break;\n        }\n        const cur = nums1[i];\n        const cur_k = nums2[k];\n\n        if (cur_k - cur !== third_possible) {\n            counter++;\n            continue;\n        }\n        k++;\n    }\n    if (counter <= 2) {\n        ret = Math.min(ret, third_possible);\n    }\n    return ret;\n};\n```
['Sorting', 'JavaScript']