[Python] Short solution, explained
Notice, that what we have in the end is sum array X and array X + 2k. It seems very familiar and you can use the greedy idea of 954. Array of Doubled Pairs, but
Notice, that what we have in the end is sum array `X` and array `X + 2k`. It seems very familiar and you can use the greedy idea of 954. Array of Doubled Pairs, but now pairs are not doubled but with constant difference. How to find difference? It can be one of `n-1` numbers: `a1 - a0, a2 - a0, ...`. Also we need to make sure that difference is positive and can be divided by `2`.\n\n#### Complexity\nTime complexity is `O(n^2)`, space is `O(n)`.\n\n#### Code\n```python\nclass Solution:\n    def recoverArray(self, nums):\n        def check(nums, k):\n            cnt, ans = Counter(nums), []\n            for num in nums:\n                if cnt[num] == 0: continue\n                if cnt[num + k] == 0: return False, []\n                cnt[num] -= 1\n                cnt[num + k] -= 1\n                ans += [num + k//2]\n            return True, ans\n            \n        nums = sorted(nums)\n        n = len(nums)\n        for i in range(1, n):\n            k = nums[i] - nums[0]\n            if k != 0 and k % 2 == 0:\n                a, b = check(nums, k)\n                if a: return b\n```\n\nIf you have any question, feel free to ask. If you like the explanations, please **Upvote!**
['Greedy']