Skip to content

Practice Minimum Array Changes to Make Differences Equal

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3224
LeetCode Problem

Minimum Array Changes to Make Differences Equal

Problem Statement

Given nums of even length n and an integer k, one change replaces an element with any integer from 0 through k. Find the fewest changes needed so that every mirrored pair has the same absolute difference: |nums[i] - nums[n - 1 - i]| must equal a common integer X. You may choose X and may make zero changes.

Source: Minimum Array Changes to Make Differences Equal on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,0,1,2,4,3], k = 4
Output
2

# Example 2

Input
nums = [0,1,2,3,3,6,5,4], k = 6
Output
2

Constraints

2 <= n == nums.length <= 10^5
n is even.
0 <= nums[i] <= k <= 10^5

Related LeetCode Problems

Practice more problems similar to Minimum Array Changes to Make Differences Equal.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.