JavaScript
The idea is coming from https://leetcode.com/problems/minimum-moves-to-make-array-complementary/discuss/953078/C%2B%2B-Prefix-sum-O(n-%2B-limit)-with-detailed-e
The idea is coming from https://leetcode.com/problems/minimum-moves-to-make-array-complementary/discuss/953078/C%2B%2B-Prefix-sum-O(n-%2B-limit)-with-detailed-examples\n```\nvar minMoves = function(nums, limit) {\n    let n = nums.length;\n    let map = new Map();\n    for(let i = 0; i < n / 2; i++) {\n        let a = nums[i];\n        let b = nums[n - i - 1];\n        let lo = Math.min(a, b) + 1;\n        let hi = Math.max(a, b) + limit + 1;\n        map.set(lo, (map.get(lo) || 0) - 1);\n        map.set((a+b), (map.get(a+b) || 0) - 1);\n        map.set((a+b+1), (map.get(a+b+1) || 0) + 1)\n        map.set(hi, (map.get(hi) || 0) + 1);\n    }\n\n    let out = n;\n    let cur = n;\n    for(let i = 0; i <= limit * 2; i++) {\n        if (map.has(i)) {\n            cur += map.get(i);\n            if (out > cur) {\n                out = cur;\n            }\n        }\n    }\n    return out;\n};
[]