[C++] O(n log n)
\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& a, vector<int>& b) {\n        sort(a.begin(), a.end());\n        sort(b.begin(), b.end());
```\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& a, vector<int>& b) {\n        sort(a.begin(), a.end());\n        sort(b.begin(), b.end());\n        int ans = 1e9;\n        for(int i = 0; i < 3; i++) {\n            int last = a[i];\n            int k = 1;\n            for(int j = i + 1; j < a.size() && k < b.size(); j++) {\n                if(a[j] - last == b[k] - b[k - 1]) {\n                    k++;\n                    last = a[j];\n                }\n            }\n            if(k == b.size()) {\n                ans = min(ans, b[0] - a[i]);\n            }\n        }\n        return ans;\n    }\n};\n```
[]