C++,Java <python HashMap Efficient Solution
JAVA SOLUTION-\n\n\n\n\nclass Solution {\nboolean isPossibleMatch(int []nums1,int nums2[]){\nint i=0,j=0,stepleft=2;\nwhile(i<nums1.length&&j<nums2.length){\nif
JAVA SOLUTION-\n\n\n\n```\nclass Solution {\nboolean isPossibleMatch(int []nums1,int nums2[]){\nint i=0,j=0,stepleft=2;\nwhile(i<nums1.length&&j<nums2.length){\nif(nums1[i]==nums2[j]){\ni++;\nj++;\n}else{\ni++;\nstepleft--;\nif(stepleft<0){\nreturn false;\n}\n}\n}\nreturn j==nums2.length&&(i-j)<=2;\n}\n\npublic int minimumAddedInteger(int[] nums1, int[] nums2) {\nArrays.sort(nums1);\nArrays.sort(nums2);\nMap<Integer, Integer> count = new HashMap<>();\nint min = Integer.MAX_VALUE;\n\n    for (int i = 0; i < nums1.length; i++) {\n        for (int j = 0; j < nums2.length; j++) {\n            int diff = nums2[j] - nums1[i];\n            count.put(diff, count.getOrDefault(diff, 0) + 1);\n        }\n    }\n    \n    for (Map.Entry<Integer, Integer> entry : count.entrySet()) {\n        int diff = entry.getKey();\n        int[] a = new int[nums1.length];\n        \n        for (int i = 0; i < nums1.length; i++) {\n            a[i] = nums1[i] + diff;\n        }\n        \n        Arrays.sort(a);\n        if (isPossibleMatch(a, nums2)) {\n            min = Math.min(min, diff);\n        }\n    }\n    \n    return min;\n}\n}\n```\nC++ Solution \n```\n#include <vector>\n#include <algorithm>\n#include <unordered_map>\n#include <climits>\n\nusing namespace std;\n\nclass Solution {\npublic:\n    bool isPossibleMatch(vector<int>& nums1, int* nums2, int size2) {\n        int i = 0;\n        int j = 0;\n        int stepleft = 2;\n        while (i < nums1.size() && j < size2) {\n            if (nums1[i] == nums2[j]) {\n                i++;\n                j++;\n            } else {\n                i++;\n                stepleft--;\n                if (stepleft < 0) {\n                    return false;\n                }\n            }\n        }\n        return j == size2 && (i - j) <= 2;\n    }\n\n    int minimumAddedInteger(vector<int>& nums1, int* nums2, int size2) {\n        sort(nums1.begin(), nums1.end());\n        sort(nums2, nums2 + size2);\n        unordered_map<int, int> count;\n        int min_val = INT_MAX;\n\n        for (int i = 0; i < nums1.size(); i++) {\n            for (int j = 0; j < size2; j++) {\n                int diff = nums2[j] - nums1[i];\n                count[diff]++;\n            }\n        }\n\n        for (auto& entry : count) {\n            int diff = entry.first;\n            vector<int> a(nums1.size());\n            for (int i = 0; i < nums1.size(); i++) {\n                a[i] = nums1[i] + diff;\n            }\n\n            sort(a.begin(), a.end());\n            if (isPossibleMatch(a, nums2, size2)) {\n                min_val = min(min_val, diff);\n            }\n        }\n\n        return min_val;\n    }\n};\n\n```\nPYTHON SOLUTION -`\n```\nfrom collections import defaultdict\n\nclass Solution:\n    def isPossibleMatch(self, nums1, nums2):\n        i = 0\n        j = 0\n        stepleft = 2\n        while i < len(nums1) and j < len(nums2):\n            if nums1[i] == nums2[j]:\n                i += 1\n                j += 1\n            else:\n                i += 1\n                stepleft -= 1\n                if stepleft < 0:\n                    return False\n        return j == len(nums2) and (i - j) <= 2\n\n    def minimumAddedInteger(self, nums1, nums2):\n        nums1.sort()\n        nums2.sort()\n        count = defaultdict(int)\n        min_val = float(\'inf\')\n        \n        for i in range(len(nums1)):\n            for j in range(len(nums2)):\n                diff = nums2[j] - nums1[i]\n                count[diff] += 1\n        \n        for diff, freq in count.items():\n            a = [0] * len(nums1)\n            for i in range(len(nums1)):\n                a[i] = nums1[i] + diff\n            \n            a.sort()\n            if self.isPossibleMatch(a, nums2):\n                min_val = min(min_val, diff)\n        \n        return min_val\n\n\n```\n`\n
['C', 'Python', 'Java']