clean code with good explanation
Intuition\n Describe your first thoughts on how to solve this problem. \n##### Let l be the nums[i], and r be the nums[n-i-1]\n1. All pair sum must in the range
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n##### Let `l` be the `nums[i]`, and `r` be the `nums[n-i-1]`\n1. All pair sum must in the range `[2, limit*2]`.\n2. By one step modification, the max sum that we can get is `max(l, r) + limit` and the min sum that we can get is `min(l, r) + 1`.\n3. When the target sum out of the range `[min(l, r) + 1, max(l, r) + limit]`, two modifications are required.\n4. We start with `n` modifications which is the max number that we need. And we store the action: `+1` or `-1` in each key point, then we could compute prefix sum to find the optimized number of modification that we need.\n##### Here are all the key points need to be handled\n1. At `min(l, r) + 1` we do `-1`, since this is the lower bound for the one step modification.\n2. At `max(l, r) + limit + 1` we do `+1`, since we are out of the upper bound for the one step modification.\n3. At `l+r` we do `-1`, since no modifications are required.\n4. At `l+r+1` we do `+1`, since we are no more at the prefect position as `l+r`, one modification is required.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create a list to store all the key points for each possible target sum.\n2. Find the min number of moves by computing prefix sum index by index.\n# Complexity\n- Time complexity: O(n + limit)\n- Creating the list takes O(n), computing prefix sum and find the min value takes O(limit).\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(limit)\n- The size of the list only depends on the limit.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minMoves(self, nums: List[int], limit: int) -> int:\n        # prepare the list for computing prefix sum\n        n = len(nums)\n        pre_sum = [0] * (2 * limit + 2)\n        for i in range(n // 2):\n            a, b = nums[i], nums[n - i - 1]\n            min_val = min(a, b)\n            max_val = max(a, b)\n            pre_sum[min_val + 1] -= 1\n            pre_sum[min_val + max_val] -= 1\n            pre_sum[min_val + max_val + 1] += 1\n            pre_sum[max_val + limit + 1] += 1\n        # get the min number of moves by computing the prefix sum\n        res = n\n        cur = n\n        for i in range(2, 2 * limit + 1):\n            cur += pre_sum[i]\n            res = min(res, cur)\n        return res\n```
['Prefix Sum', 'Python3']