C++ || O(N^2) || EASY APPROACH EXPLAINED || HASHMAP
This solution is next level of question : https://leetcode.com/problems/find-original-array-from-doubled-array/\n\nLets say we have any arbitary value for K ,\n
This solution is next level of question : https://leetcode.com/problems/find-original-array-from-doubled-array/\n\nLets say we have any arbitary value for K ,\n* We will first sort the array and store frequency all the element in  a map ;\n* We will go by each  element and check if that nums[i] and nums[i] +k*2 is present in map if yes we will push  it to answers and subtract 1 value in map for both  nums[i] and nums[i] +k*2 ;\n*  if condition do not staicify we will break loop and solution is not present for given value of K .\n* So we will follow above steps for all possible values of k \n* To get all  possible values of k  we will sutract first elemt in nums from each value present in nums. (as k will be same for all elements including first ).\n\ncode : \n```\nclass Solution {\npublic:\n    vector<int> recoverArray(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        for(int i=1;i<n;i++){\n            int k = nums[i]-nums[0];\n            if(k%2!=0 || k==0){\n                continue;\n            }\n            unordered_map<int,int> mp;\n            for(int i=0;i<n;i++){\n                mp[nums[i]]++;\n            }\n            vector<int> ans;\n            bool gotit=true;\n            for(int i=0;i<n;i++){\n                if(mp[nums[i]]!=0){\n                    if(mp.count(nums[i]+k)!=0 && mp[nums[i]+k]>0){\n                        ans.push_back(nums[i]+k/2);\n                        mp[nums[i]]--;\n                        mp[nums[i]+k]--;\n                    }\n                    else{\n                        gotit=false;\n                        break;\n                    }\n                }\n            }\n            if(gotit){\n                return ans;\n            }\n            \n        }\n        return {};\n    }\n};\n```\n\n\n\n
[]