Python Hash Table, sorting with detailed explanation, fast and efficient
\nclass Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        counter = Counter(nums)  # counter\n        nums = sorted(counter)   # sor
```\nclass Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        counter = Counter(nums)  # counter\n        nums = sorted(counter)   # sorted unique numbers\n\n        hm = nums[-1]            # the max number must be the max in the "higher" group\n        for num in nums[:-1]:    # test the corresponding number in the "lower" group. Not necessarily the min.\n            k, m = divmod(hm - num, 2)  # derived "k"\n            if m:                       # there is a remainder, so they are partners\n                continue\n            ans = []                    # to store the answer in case this will succeed\n            cnt = counter.copy()        # not sure if there is a better way than this\n            for n in nums:              # validation starts now.  start with the smallest value\n                c = cnt.pop(n)          # its number\n                if c == 0:              # this value must have been fully considered in the "higher" group\n                    continue\n                o = n + k                # derived origin\n                p = o + k                # derived partner\n                if cnt[p] >= c:          # "p" should have enough number. If it has more, the remaining join "lower".\n                    cnt[p] -= c          # reduce the count\n                    ans.extend([o] * c)  # add them into "ans"\n                else:                    # validation failed\n                    break\n            else:\n                return ans\n```
['Hash Table', 'Sorting']