Heap + Hash Map O(N) Solution
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```\nclass Solution {\npublic:\n    bool isValid(int x, vector<int> &nums1, vector<int> &nums2, int n1, int n2) {\n        unordered_map<int, int> mp;\n        for (int i = 0; i < n1; i++) {\n            mp[nums1[i] + x]++;\n        }\n        for (int j = 0; j < n2; j++) {\n            if (mp[nums2[j]] > 0) {\n                mp[nums2[j]]--;\n            } else {\n                return false;\n            }\n        }\n        return true;\n    }\n    int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) {\n        int n1 = nums1.size(), n2 = nums2.size(), ans = INT_MAX, minNums2 = INT_MAX;\n        priority_queue<int> pq;\n        for (int i = 0; i < n1; i++) {\n            pq.push(nums1[i]);\n            if (pq.size() > 3) {\n                pq.pop();\n            }\n        }\n        for (int j = 0; j < n2; j++) {\n            minNums2 = min(minNums2, nums2[j]);\n        }\n        while (!pq.empty()) {\n            int x = minNums2 - pq.top();\n            pq.pop();\n            if (isValid(x, nums1, nums2, n1, n2)) {\n                ans = min(ans, x);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']