Tap here to switch tabs
Problem
Submissions

Problem: Minimum Moves to Make Array Complementary

Try to solve the Minimum Moves to Make Array Complementary problem.

Statement

Given an integer array nums of even length n and an integer limit.

In 11 move, you can replace any integer in nums with any integer value between 11 and limit, inclusive.

The array nums is complementary if nums[i] ++ nums[n - 1 - i] is equal to the same constant sum for every index i such that 0≤0 \leq i << n.

Return the minimum number of moves required to make nums complementary.

Constraints:

  • n ==== nums.length

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤\leq limit ≤105\leq 10^5

  • n is even.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Moves to Make Array Complementary

Try to solve the Minimum Moves to Make Array Complementary problem.

Statement

Given an integer array nums of even length n and an integer limit.

In 11 move, you can replace any integer in nums with any integer value between 11 and limit, inclusive.

The array nums is complementary if nums[i] ++ nums[n - 1 - i] is equal to the same constant sum for every index i such that 0≤0 \leq i << n.

Return the minimum number of moves required to make nums complementary.

Constraints:

  • n ==== nums.length

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤\leq limit ≤105\leq 10^5

  • n is even.