Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Modulo Alternating I

Try to solve the Minimum Operations to Make Array Modulo Alternating I problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can choose any element in nums and increase or decrease it by 11.

The array nums is considered modulo alternating if there exist two distinct integers xx and yy such that 0≤x,y<k0 \le x, y < k and:

  • nums[i] % k is equal to xx for all even indices ii.

  • nums[i] % k is equal to yy for all odd indices ii.

Return the minimum number of operations required to make nums modulo alternating.

Constraints:

  • 1≤1 \le nums.length ≤100\le 100

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 2≤2 \le k ≤100\le 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Modulo Alternating I

Try to solve the Minimum Operations to Make Array Modulo Alternating I problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can choose any element in nums and increase or decrease it by 11.

The array nums is considered modulo alternating if there exist two distinct integers xx and yy such that 0≤x,y<k0 \le x, y < k and:

  • nums[i] % k is equal to xx for all even indices ii.

  • nums[i] % k is equal to yy for all odd indices ii.

Return the minimum number of operations required to make nums modulo alternating.

Constraints:

  • 1≤1 \le nums.length ≤100\le 100

  • 1≤1 \le nums[i] ≤109\le 10^9

  • 2≤2 \le k ≤100\le 100