Simple search | brute force | commented
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def minimumAddedInteger(self, nums1: List[int], nums2: List[int]) -> int:\n        # Min, Max x: -1000, 1000\n        # nums1 == nums2: can be done with a linear scan, all we need to check is all elements of nums2 should be in nums1\n        nums1.sort()\n        nums2.sort()\n        N, M = len(nums1), len(nums2)\n        def equals(diff: int) -> bool:\n            # i, j: nums1, nums2\n            i = j = 0\n            while i < N and j < M:\n                if nums2[j] == nums1[i] + diff:\n                    j += 1\n                i += 1\n            return True if j == M else False\n        \n        for x in range(-1000, 1001):\n            if equals(x): return x\n\n        return -1\n# old ----------------------------------------------------------------------------------------\n        # Naive, brute force for x\n        nums1.sort()\n        nums2.sort()\n\n        def listMatches(diff: int) -> bool:\n            i, n = 0, len(nums2)\n            j, m = 0, len(nums1)\n            extras = 0\n\n            while j < m and i < n:\n                if extras > 2: return False\n\n                if nums2[i] == nums1[j] + diff:\n                    i += 1\n                    j += 1\n                else:\n                    extras += 1\n                    j += 1\n            \n            while j < m: \n                extras += 1\n                j += 1\n\n            return True if extras <= 2 else False\n        \n        for x in range(-1000, 1001):\n            if listMatches(x):\n                return x\n        \n```
['Python3']