Ruby Solution in O(n^2) (100%/100%)
Intuition\nIt\'s easy to check if a possible value of k works, and to create the array if you know k.  Find all possible values of k, find one that works, and g
# Intuition\nIt\'s easy to check if a possible value of k works, and to create the array if you know k.  Find all possible values of k, find one that works, and generate the array.\n\n# Approach\n1. Sort the numbers (to better iterate later)\n2. Find how often each number occurs in the array\n3. Find the possibilities for j.  (I\'m using j to represent 2k.  Note that j must be even.  Also, it can\'t be 0, so we shift to remove 0 from the array.)\n4. Check possible j values until finding one that works\n    a. Start with the first element ele, and decrement ele and ele + j in the count.  If this isn\'t possible, the value of j is wrong.\n    b. Go through the rest of the elements in the array (as long as they haven\'t been removed yet).  If you get through all the elements, return true.\n5. Find the array for that j value\n    a. Basically the same process as checking j, but in addition to decrementing the count, add ele + k to an array.\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\ndef recover_array(nums)\n    nums.sort!\n    count = Hash.new(0)\n    nums.each { |num| count[num] += 1 }\n\n    possibilities = nums.uniq.map { |num| num - nums[0] }\n    possibilities.shift\n    possibilities.reject! { |j| j % 2 == 1 }\n\n    j = false\n    i = 0\n\n    until j\n        if valid?(nums,count.dup,possibilities[i])\n            j = possibilities[i]\n        end\n        i += 1\n    end\n\n    find_arr(nums,count,j)\nend\n\ndef valid?(nums,count,j)\n    n = nums.length / 2\n    i = 0\n\n    while n > 0\n        if count[nums[i]] > 0\n            count[nums[i]] -= 1\n            count[nums[i] + j] -= 1\n            return false if count[nums[i] + j] < 0\n            n -= 1\n        end\n        i += 1\n    end\n    true\nend\n\ndef find_arr(nums,count,j)\n    arr = []\n    n = nums.length / 2\n    k = j / 2\n    i = 0\n\n    while n > 0\n        if count[nums[i]] > 0\n            count[nums[i]] -= 1\n            count[nums[i] + j] -= 1\n            arr << nums[i] + k\n            n -= 1\n        end\n        i += 1\n    end\n    arr\nend\n```
['Ruby']