Python3: Sweep Line with Comments
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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        # 0 1 2 3 4 5\n        # 1 4 2 1 5 3 # 5\n\n        # create an interval [i, n - i - 1] -> [min, max]\n        N = len(nums) # 4 -> 2\n        res, cur = N, N # at maximum N number of changes\n        ranges = [0] * (2 * limit + 2)\n\n        # fill the ranges with the marginal increase in the number of changes\n            # for current interval,\n                # if the target change is out side of changes that can be made by\n                # changing one element; \n                # left: min + 1; -= 1 - come in the range\n                # right: max + limit + 1; += 1 - goes out of the range\n                # same: min + max; -= 1\n                # not same: min + max + 1; += 1\n        for i in range(N // 2):\n            a, b = nums[i], nums[N - i - 1]\n            s, e = min(a, b), max(a, b)\n\n            # update the ranges\n            ranges[s + 1] -= 1 # in the left bound\n            ranges[s + e] -= 1 # is the same\n            ranges[s + e + 1] += 1 # is not the same\n            ranges[e + limit + 1] += 1 # if out of bound\n\n        for i in range(2, 2 * limit + 1):\n            # update the cur\n            cur += ranges[i]\n\n            # update the res\n            res = min(res, cur)\n            \n        return res\n```
['Python3']