Easy to understand Hashmap solution C++
\nclass Solution {\npublic:\n    vector<int> recoverArray(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        \n  
```\nclass Solution {\npublic:\n    vector<int> recoverArray(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        \n        map<int,int> mp;\n        for(int i=0;i<n;i++)\n            mp[nums[i]]++;\n        int l=0;\n        int r=(n/2);\n        int gap=0;\n        while(l<r)\n        {\n            int dif=nums[r]-nums[l];\n            if(dif%2!=0)\n            {\n                r--;\n                continue;\n            }\n            map<int,int> temp=mp;\n            for(auto it=temp.begin();it!=temp.end();it++)\n            {\n                if(temp[it->first]==0)\n                    continue;\n                int ele1=it->first;\n                int ele2=it->first+dif;\n                if(temp.find(ele2)==temp.end())\n                    break;\n                if(temp[ele1]>temp[ele2])\n                    break;\n                else\n                {\n                    temp[ele2]-=temp[ele1];\n                    temp[ele1]=0;\n                }\n                \n            }\n            bool is=true;\n            for(auto it=temp.begin();it!=temp.end();it++)\n            {\n                if(temp[it->first]>0)\n                {\n                    is=false;\n                    break;\n                }\n                    \n            }\n            if(is && dif%2==0)\n            {\n                gap=dif;\n                break;\n            }\n            r--;\n        }\n        \n        vector<int> ans;\n        for(auto it= mp.begin();it!=mp.end();it++)\n        {\n           if(mp[it->first]==0)\n               continue;\n            int sz=mp[it->first];\n            int ele2=it->first+gap;\n            for(int i=0;i<sz;i++)\n                ans.push_back((it->first+ele2)/2);\n            mp[ele2]-=mp[it->first];\n                \n        }\n    \n        return ans;\n        \n        \n    }\n};\n```
['C', 'C++']