simple c++ solution  with explanation(n^2)
since it\'s given that atleast one valid answer is always possible , therefore for every index  i  of array there is one index j (i!=j) \nsuch that   |array[ j 
since it\'s given that atleast one valid answer is always possible , therefore for every index  i  of array there is one index j (i!=j) \nsuch that   |array[ j ]  - array[ i ] | == 2*k ,\nwhere k is the positive integer given in question.\n\nlets first sort the array to simplify things for us.\n\nnow let\'s say we start checking for all valid k\'s   from  first element ( 0th element index wise) . there can be as many as n-1 different k we can get  \ni.e    (arr[ 1 ] -arr [ 0 ] ), (arr[ 2 ] -arr [ 0 ] ) , (arr[ 3 ] -arr [ 0 ] ) ..................... (arr[ n-1 ] -arr [ 0 ] )\nat max  this number can be 1000 as given in constraints.\n\nnow for each such even value of k we try to build our original array  in  O(n) time  and if possible we will return that array as \nour answer . we will try to find our valid answer till we get one  using these ( n-1 ) k\'s.\n\nTime -   as there can be n-1 values of k and for each k to check valid ans o(n) time will require \n          O(n^2)\n\t\t  \n```\nclass Solution {\npublic:\n    vector<int> recoverArray(vector<int>& nums) {\n        vector<int> ans;\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])/2;\n            if((nums[i]-nums[0])%2==1 || k<1)continue;\n\n            bool possible=true;\n            vector<bool> left(n,true);\n            vector<int> temAns;\n            int upper=i;\n        \n            for(int lower=0;lower<n;lower++){\n                if(!left[lower])continue;\n                if(upper==lower)upper++;\n                while(upper<n && nums[upper]-nums[lower]<=2*k){\n                if(nums[upper]-nums[lower]==2*k){\n                    temAns.push_back(nums[lower]+k);\n                    left[upper]=left[lower]=false;\n                    upper++;\n                    break;\n                }\n                    upper++;\n                }\n                if(left[lower]){\n                    possible=false;\n                    break;\n                }\n                \n            }\n            if(possible){\n                ans=temAns;\n                break;\n            }\n        }\n        return ans;\n    }\n};\n```\n
['C']