[Java] try all possible k
\n   public int[] recoverArray(int[] nums) {\n        var count = new HashMap<Integer, Integer>();\n        int max = 0;\n        for (int a : nums) {\n        
```\n   public int[] recoverArray(int[] nums) {\n        var count = new HashMap<Integer, Integer>();\n        int max = 0;\n        for (int a : nums) {\n            max = Math.max(max, a);\n            count.put(a, count.getOrDefault(a, 0) + 1);\n        }\n        var uniques = new ArrayList<Integer>(count.keySet());\n        Collections.sort(uniques);\n        \n        var possibleK = new ArrayList<Integer>();\n        for (int i = 1, kk; i<uniques.size(); i++) {\n            kk = uniques.get(i) - uniques.get(0);\n            if (kk % 2 == 0) {\n                possibleK.add(kk / 2);\n            }\n        }\n        \n        for (int k : possibleK) {\n            var cloneCount = (HashMap<Integer, Integer>) count.clone();\n            var res = tryK(uniques, cloneCount, k, nums.length/2);\n            if (res != null) {\n                return res;\n            }\n        }\n        \n        return null;\n\n    }\n    \n    public int[] tryK(List<Integer> uniques, HashMap<Integer, Integer> count, int k, int n) {\n        var ans = new int[n];\n        int cur = 0;\n        for (int a : uniques) {\n            if (count.getOrDefault(a, 0) == 0) \n                continue;\n            int c = count.get(a);\n            int d = count.getOrDefault(a + 2*k, 0) - c;\n            if (d < 0)\n                return null;\n            while (c-- > 0) {\n                ans[cur++] = a + k;\n            }\n            count.remove(a);\n            count.put(a+2*k, d);\n        }\n        \n        return ans;\n    }\n```
[]