[Python3] Just Working Code - 27.09.2024
\npython3 [1 python3]\nclass Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        cnt = Counter(nums)\n        for
\n```python3 [1 python3]\nclass Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        cnt = Counter(nums)\n        for i in range(1, len(nums)): \n            diff = nums[i] - nums[0]\n            if diff and diff&1 == 0: \n                ans = []\n                freq = cnt.copy()\n                for k, v in freq.items(): \n                    if v: \n                        if freq[k+diff] < v: break \n                        ans.extend([k+diff//2]*v)\n                        freq[k+diff] -= v\n                else: return ans \n```\n```python3 [2 python3]\nclass Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        val, n = nums[0], len(nums)\n\n        for j in range(1, n) :\n            if nums[j] == val :\n                continue \n\n            if nums[j] % 2 == val % 2 :\n                k = (nums[j] - val) // 2 \n\n                visit, i, ans = [False for _ in range(len(nums))], 0, []\n\n                while j < n :\n                    if visit[i] :\n                        i += 1 \n                    elif visit[j] :\n                        j += 1 \n                    elif nums[i] + 2 * k == nums[j] :\n                        ans.append(nums[i] + k)\n                        visit[i] = True \n                        visit[j] = True \n                        i += 1 \n                        j += 1 \n                    elif nums[i] + 2 * k > nums[j] :\n                        j += 1 \n                    else :\n                        break \n\n                if len(ans) == n // 2 :\n                    return ans\n```\n
['Python3']