Simple java solution
Complexity\n- Time complexity: O(n^2 log n)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution {\n    public int minimumAddedInteger(int[] nums1, int[] num
# Complexity\n- Time complexity: $$O(n^2 log n)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution {\n    public int minimumAddedInteger(int[] nums1, int[] nums2) {\n        Arrays.sort(nums1);\n        Arrays.sort(nums2);\n        int size1=nums1.length,size2=nums2.length;\n        Map<Integer,Integer> nm=new HashMap<>();\n        for(int i=0;i<size1;i++)\n        {\n            for(int j=0;j<size2;j++)\n            {\n                int val=nums2[j]-nums1[i];\n                nm.put(val, nm.getOrDefault(val,0)+1);\n            }\n        }\n        int mini=Integer.MAX_VALUE;\n        for(int k:nm.keySet())\n        {\n            int arr[]=new int[size1];\n            for(int i=0;i<size1;i++)\n            {\n                arr[i]=nums1[i]+k;\n            }\n            Arrays.sort(arr);\n            if(check(arr,nums2))\n            {\n                mini=Math.min(mini,k);\n            }\n        }\n        return mini;\n    }\n    private boolean check(int nums1[], int nums2[])\n    {\n        int i=0,j=0,val=2;\n        while(i<nums1.length && j<nums2.length)\n        {\n            if(nums1[i] == nums2[j])\n            {\n                i++;\n                j++;\n            }\n            else\n            {\n                i++;\n                val--;\n                if(val < 0)\n                {\n                    return false;\n                }\n            }\n        }\n        return j == nums2.length && (i-j) <= 2;\n    }\n}\n```
['Java']