Very easy Python solution with detailed expanation
Intuition\n Describe your first thoughts on how to solve this problem. \nAs other solution describe:\nIf x + y = T, the cost is 0.\nIf min(x, y) + 1 > T, the co
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAs other solution describe:\nIf `x + y = T`, the cost is 0.\nIf `min(x, y) + 1 > T`, the cost is 2 -- we need to decrease both x and y.\nIf `max(x, y) + limit < T`, the cost is 2 -- we need to increase both x and y.\nOtherwise the cost is 1.\n\n# Approach\nNow let\'s keep track of intervals of targets where cost is 1 for each number, also we keep track of targets which make the cost 0 for each of the given pair of numbers. \nThan cost for each target should be: \n```\nN (at most we change all numbers) - (number intervals which decrease the cost by 1 each) - (number of zero_moves for this target)\n```\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nWe traverse 2 times, so time complexity N\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nwe store 3 dictionaries of N each -> space complexity is also N\n# Code\n```\nfrom collections import defaultdict\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        starts, ends, zero_moves = defaultdict(int), defaultdict(int), defaultdict(int)\n        N = len(nums)\n        for i in range(N // 2):\n            x, y = nums[i], nums[N-i-1]\n            starts[min(x, y)+1] += 1\n            ends[max(x,y)+limit] += 1\n            zero_moves[x+y] += 1\n        result = float(\'inf\')\n        intervals = 0\n        for target in range(2, 2*limit+1):\n            intervals += starts[target]\n            cost = N - intervals - zero_moves[target]\n            result = min(cost, result)\n            intervals -= ends[target]\n        return result\n```
['Python3']