difference array

```swift []
class Solution {
    func minMoves(_ nums: [Int], _ limit: Int) -> Int {
        let n = limit * 2 + 2
        var pref = Array(repeating:0, count: n)
        var ans = Int.max
        var count = 0

        for i in 0..<nums.count / 2 {
            let min_num = min(nums[i], nums[nums.count - 1 - i])
            let max_num = max(nums[i], nums[nums.count - 1 - i])

            pref[2] += 2
            //pref[n - 1] -= 2

            pref[min_num + 1] -= 1
            pref[max_num + limit + 1] += 1

            pref[min_num + max_num] -= 1
            pref[min_num + max_num + 1] += 1
        }

        for i in 2..<pref.count - 1 {
            count += pref[i]
            ans = min(ans, count)
        }
        return ans
    }
}
```
['Swift']