🔥Brute Force - Beginner Friendly | Clean Code | C++ |
Code\n\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) {\n        map<int, int> n1;\n        for (auto x : nums1
# Code\n```\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) {\n        map<int, int> n1;\n        for (auto x : nums1)\n        {\n            n1[x]++;\n        }\n\n        int res = INT_MAX;\n        for (int i = 0; i < nums1.size(); i++) \n        {\n            map<int, int> n2 = n1;\n            int diff = nums2[0] - nums1[i];\n            bool isP = true;\n            \n            for (int k = 0; k < nums2.size(); k++) \n            {\n                if (n2.find(nums2[k] - diff) == n2.end()) \n                {\n                    isP = false;\n                } \n                else \n                {\n                    n2[nums2[k] - diff]--;\n                    if (n2[nums2[k] - diff] == 0)\n                    {\n                        n2.erase(nums2[k] - diff);\n                    }\n                }\n            }\n            if (isP)\n            {\n                res = min(res, diff);\n            }\n        }\n        \n        return res;\n    }\n};\n\n```
['C++']