You're given an even-sized integer array nums of length n, and an integer k representing the maximum value allowed in the array. Your goal is to transform this array into a perfectly symmetric one with respect to absolute differences.
In one operation, you can replace any element with any integer in the range [0, k]. You need to ensure that there exists some integer X such that:
|nums[i] - nums[n-1-i]| = X for all valid indices i
In other words, the absolute difference between each pair of elements that are symmetric about the center must be exactly the same. Return the minimum number of changes needed to achieve this beautiful symmetry.
Example: If nums = [1,0,1,2] and k = 2, pairs are (1,2) and (0,1) with differences 1 and 1 respectively - already symmetric!
Input & Output
Constraints
- 2 ≤ nums.length ≤ 105
- nums.length is even
- 0 ≤ nums[i] ≤ k ≤ 105
- All elements are initially within the range [0, k]