Sweep line
Code\n\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        cnt = Counter()\n        i, n = 0, len(nums)\n        p = [0] * (2
# Code\n```\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        cnt = Counter()\n        i, n = 0, len(nums)\n        p = [0] * (2 * limit + 2)\n        while i < n // 2:\n            cnt[nums[i] + nums[n-1-i]] += 1\n            p[min(nums[i], nums[n-1-i]) + 1] += 1\n            p[max(nums[i], nums[n-1-i]) + limit + 1] -= 1\n            i += 1\n        \n        v, ans = 0, inf\n        for q in range(2, 2 * limit + 1):\n            v += p[q]\n            ans = min(ans, v - cnt[q] + (n // 2 - v) * 2)\n        return ans\n```
['Python3']