Checking pairs
Code
# Code
```cpp []
class Solution {
public:
    vector<int> recoverArray(vector<int>& a) {
        int n = a.size(), diff = 0;
        sort(a.begin(), a.end());
        map<int, int> mpp;
        for (int i = 0; i < n; i++)
            mpp[a[i]]++;
        for (int i = 1; i < n; i++) {
            diff = a[i] - a[0];
            if (diff & 1)
                continue;
            map<int, int> mp1 = mpp;
            bool c = true;
            for (int j = 0; j < n; j++) {
                if (mp1[a[j]] == 0)
                    continue;
                if (mp1[a[j] + diff] == 0) {
                    c = false;
                    break;
                }
                mp1[a[j]]--;
                mp1[a[j] + diff]--;
            }
            if (c && diff > 0)
                break;
        }
        vector<int> ans;
        for (int i = 0; i < n; i++) {
            if (mpp[a[i]] == 0)
                continue;
            if (mpp[a[i]] && mpp[a[i] + diff]) {
                ans.push_back(a[i] + diff / 2);
                mpp[a[i]]--;
                mpp[a[i] + diff]--;
            }
        }
        return ans;
    }
};
```
['C++']