O(n) C++ solution
Intuition\nWe\'ll check the difference of maximum value of nums2 and top 3 maximum values of nums1, and for each difference we\'ll check if the difference can b
# Intuition\nWe\'ll check the difference of maximum value of nums2 and top 3 maximum values of nums1, and for each difference we\'ll check if the difference can be applied to all other values of nums1 and change it to nums2, the minimum of these 3 differences gives the actual answer\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n+m)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) {\n        int m1 = 0, m2 = 0;\n        unordered_map<int,int> mp1,mp2;\n        for(int i:nums1){\n            m1 = max(m1, i);\n            mp1[i]++;\n        }\n        for(int i:nums2){\n            m2 = max(m2, i);\n            mp2[i]++;\n        }\n\n        int ans = max(m1,m2);\n\n        for(int t=0;t<3;t++){\n            int diff = m2-m1;\n            bool flag = true;\n            for(auto &x:mp2){\n                if(mp1[x.first-diff]<x.second){\n                    flag = false;\n                    break;\n                }\n            }\n            if(flag)\n                ans = min(ans, diff);\n            mp1[m1]--;\n            m1 = 0;\n            for(auto &x:mp1){\n                if(x.second)\n                    m1 = max(m1, x.first);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']