Easy Java solution O(n*log(n))
Complexity\n- Time complexity: O(n*log(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \
# Complexity\n- Time complexity: O(n*log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumAddedInteger(int[] nums1, int[] nums2) {\n        Arrays.sort(nums2);\n        Arrays.sort(nums1);\n\n        Map<Integer, Integer> map = new HashMap<>();\n        for(int i: nums1){\n            map.put(i, map.getOrDefault(i, 0) + 1);\n        }\n\n        int ans = Integer.MAX_VALUE;\n        \n        for(int i=0; i<3; i++){\n            int x = nums2[0] - nums1[i];\n            \n            Map<Integer, Integer> m = new HashMap<>(map);\n            m.put(nums1[i] , m.getOrDefault(nums1[i], 0) - 1);\n            \n            boolean flag = true;\n\n            for(int j=1; j<nums2.length; j++){\n                int e = nums2[j] - x;\n                \n                if(m.getOrDefault(e, 0) > 0){\n                     m.put(e , m.get(e) - 1);\n                }\n                else{\n                    flag = false;\n                }\n            }\n            if(flag){\n                ans = Math.min(ans, x);\n            }\n        }\n        return ans;\n            \n    }\n}\n```
['Java']