Tap here to switch tabs
Problem
Submissions

Problem: Minimum Array Changes to Make Differences Equal

Try to solve the Minimum Array Changes to Make Differences Equal problem.

Statement

You are given an integer array nums of even length n and an integer k.

In one operation, you can choose any index i satisfying 0≤0 \leq i << n and replace nums[i] with any integer in the range [0,k][0, k].

Your goal is to choose an integer X such that for all indices i where 0≤0 \leq i << n /2/ 2, the condition ∣|nums[i] −- nums[n - i - 1]∣=X| = X holds true.

Return the minimum number of operations required to make the difference equal for all such pairs.

Constraints:

  • 2≤2 \leq n ==== nums.length ≤105\leq 10^5

  • n is even.

  • 0≤0 \leq nums[i] ≤\leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Array Changes to Make Differences Equal

Try to solve the Minimum Array Changes to Make Differences Equal problem.

Statement

You are given an integer array nums of even length n and an integer k.

In one operation, you can choose any index i satisfying 0≤0 \leq i << n and replace nums[i] with any integer in the range [0,k][0, k].

Your goal is to choose an integer X such that for all indices i where 0≤0 \leq i << n /2/ 2, the condition ∣|nums[i] −- nums[n - i - 1]∣=X| = X holds true.

Return the minimum number of operations required to make the difference equal for all such pairs.

Constraints:

  • 2≤2 \leq n ==== nums.length ≤105\leq 10^5

  • n is even.

  • 0≤0 \leq nums[i] ≤\leq k ≤105\leq 10^5