Beat 100%
\n\n\n\n# Approach\n1. Initialize the Difference Array: Create a diff array with size greater than 2 * limit (where limit is the largest possible value in the o
\n![Screenshot 2024-02-11 at 07.25.08.png](https://assets.leetcode.com/users/images/a33f1e86-d326-482d-9ba3-d51e32d45609_1707611149.1945999.png)\n\n\n# Approach\n1. Initialize the Difference Array: Create a diff array with size greater than 2 * limit (where limit is the largest possible value in the original array) to keep track of the number of changes required for each possible total value from 2 to 2 * limit.\n\n2. Update Difference Array: Iterate through the first half of the original array and update the diff array based on the range of values where each change will affect the sum of the pair of numbers.\n\n3. Calculate Minimum Number of Changes: Iterate through the diff array to calculate the minimum number of changes needed to make all pair sums equivalent.\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nfunction minMoves(nums: number[], limit: number): number {\n    const diff = new Array(2 * limit + 2).fill(0);\n    const n = nums.length;\n\n    for (let i = 0; i < n / 2; i++) {\n        const a = nums[i];\n        const b = nums[n - 1 - i];\n\n        diff[2] += 2;\n        diff[Math.min(a, b) + 1]--;\n        diff[a + b]--;\n        diff[a + b + 1]++;\n        diff[Math.max(a, b) + limit + 1]++;\n    }\n\n    let res = diff[2];\n    let current = diff[2];\n    for (let i = 3; i <= 2 * limit; i++) {\n        current += diff[i];\n        res = Math.min(res, current);\n    }\n\n    return res;\n}\n\n```
['TypeScript']