Dynamic Programming is a saviour
\n# Code\n\nclass Solution:\n    def minimumAddedInteger(self, nums1: List[int], nums2: List[int]) -> int:\n        nums1.sort()\n        nums2.sort()\n        
\n# Code\n```\nclass Solution:\n    def minimumAddedInteger(self, nums1: List[int], nums2: List[int]) -> int:\n        nums1.sort()\n        nums2.sort()\n        @cache\n        def do(pos1,pos2,rem):\n            if(pos2+1==len(nums2)):\n                return nums2[pos2]-nums1[pos1]\n            ans=nums2[pos2]-nums1[pos1]\n            for i in range(rem+1):\n                if(nums2[pos2+1]-nums1[pos1+i+1]==ans):\n                    return do(pos1+i+1,pos2+1,rem-i)\n            return float(\'inf\')\n        return min(do(0,0,2),do(1,0,1),do(2,0,0))\n```
['Dynamic Programming', 'Python3']