Difference Array
\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(n)\n- Space complexity:\n Add your space complexity here, e.g. O(n) \nO(n)\n# 
\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```\n# @param {Integer[]} nums\n# @param {Integer} limit\n# @return {Integer}\ndef min_moves(nums, limit)\n    \n    arr = Array.new(2*limit + 2) { 0 }\n    n = nums.size \n\n    i = 0\n    while i < nums.size/2\n        l = nums[i]\n        r = nums[n - 1 - i]\n        arr[0] += 2\n\n\n        one_move_min = [l,r].min + 1\n        arr[one_move_min] -= 1\n\n\n        no_move = l + r\n        arr[no_move] -= 1\n        arr[no_move + 1] += 1\n\n        one_move_max = [l,r].max + limit\n        arr[one_move_max + 1] += 1\n\n        i += 1\n    end\n\n    min_moves = 99999999\n    i = 1\n    while i < arr.size\n        arr[i] += arr[i-1]\n        min_moves = [min_moves, arr[i]].min\n        i += 1\n    end\n\n    min_moves\nend\n```
['Ruby']