Easy Video Solution 🔥 || How to 🤔 in Interview || O(N*N*N)->O(N*N)
If you like the solution Please Upvote and subscribe to my youtube channel\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nDry Run
***If you like the solution Please Upvote and subscribe to my youtube channel***\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDry Run few examples and note your observations clearly\n\n\n\n***Easy Video Explanation*** (In video I have explained O(N*N) solution at the end)\n\nhttps://youtu.be/t63FUyt0Yqo\n\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumAddedInteger(vector<int>& v1, vector<int>& v2) {\n        int ans=INT_MAX;\n        int m=v2.size();\n        int n=v1.size();\n        sort(v1.begin(),v1.end());\n        sort(v2.begin(),v2.end());\n        for(int i=0;i<n;i++) {\n            for(int j=i+1;j<n;j++) {\n                vector<int>t;\n                for(int k=0;k<n;k++) {\n                    if(k!=i && k!=j) {\n                        t.push_back(v1[k]);\n                    }\n                }\n                int diff=v2[m-1]-t[m-1];\n                int f=0;\n                for(int k=m-2;k>=0;k--) {\n                    int d=v2[k]-t[k];\n                    if(d!=diff) {\n                        f=1;\n                        break;\n                    }\n                }\n                if(f==0)\n                    ans=min(ans,v2[m-1]-t[m-1]);\n            }\n        }\n        return ans;\n    }\n};\n```\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N*N*N)\n    \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(N)\n\n# ***If you like the solution Please Upvote and subscribe to my youtube channel***\n***It Motivates me to record more videos***\n\n*Thank you* \uD83D\uDE00\n```
['Sorting', 'Simulation', 'C++']