[Python/Java] simple O(max(n, k)) method
Idea\nIf we want to make the nums complementary, having all the pairs A = nums[i], B = nums[n - 1 - i] with A + B = T. Considering a pair A = nums[i], B = nums[
**Idea**\nIf we want to make the `nums` complementary, having all the pairs `A = nums[i], B = nums[n - 1 - i] with A + B = T`. Considering a pair `A = nums[i], B = nums[n - 1 - i]`, there are 5 different situation for every such pair (A, B), given different target `T`.\n1. `2 <= T < min(A, B) + 1`, we need 2 operations to make both A, B smaller\n2. ` min(A, B) + 1 <= T < A + B`, we need 1 operation to make the larger one out of A and B smaller\n3. `T = A + B`, we need 0 operation\n4. `A + B < T < max(A, B) + limit`, we need 1 operation to make the smaller one out of A and B larger\n5. `max(A, B) + limit < T <= 2 * limit`, we need 2 operation to make both A, B larger\n\nWe calculate the boundary for each pair (A, B) and note down the corresponding operation changes as `delta`. `delta[i] = x` means we need `x` more operations when target `T` change from `i - 1` to `i`.\n\n**Complexity**\n- Time: `O(max(n, k))`\n- Space: `O(k)`\n\n**Python**\n```\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        delta = collections.Counter()\n        n = len(nums)\n        for i in range(n // 2):\n            a, b = nums[i], nums[n - 1 - i]\n            delta[2] += 2\n            delta[min(a, b) + 1] -= 1\n            delta[a + b] -= 1\n            delta[a + b + 1] += 1\n            delta[max(a, b) + limit + 1] += 1\n            \n        curr = 0            \n        res = math.inf\n        for i in range(2, 2 * limit + 1):\n            curr += delta[i]\n            res = min(res, curr)\n        return res   \n```\n\n**Java**\n```\nclass Solution {\n    public int minMoves(int[] nums, int limit) {\n        int[] delta = new int[2 * limit + 2];\n        Arrays.fill(delta, 0);\n        int n = nums.length;\n        for (int i = 0; i < n / 2; i++) {\n            int a = nums[i], b = nums[n - 1 - i];\n            delta[2] += 2;\n            delta[Math.min(a, b) + 1]--;\n            delta[a + b]--;\n            delta[a + b + 1]++;\n            delta[Math.max(a, b) + limit + 1]++;\n        }\n        int res = 2 * n, curr = 0;\n        for (int i = 2; i <= 2 * limit; i++) {\n            curr += delta[i];\n            res = Math.min(res, curr);\n        }\n        return res;\n    }\n}\n```
[]