Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Equal

med
30 min
Try to solve the Minimum Operations to Make Array Equal problem.

Statement

You are given an integer n, representing the length of an array arr where arr[i] = (2 \cdot i) + 1 for all 0≤0 \leq i << n.

In a single operation, you can choose two indices x and y such that 0≤0 \leq x, y << n, decrement arr[x] by 11, and increment arr[y] by 11.

Return the minimum number of operations required to make all elements of arr equal.

Constraints:

  • 1≤1 \leq n ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Equal

med
30 min
Try to solve the Minimum Operations to Make Array Equal problem.

Statement

You are given an integer n, representing the length of an array arr where arr[i] = (2 \cdot i) + 1 for all 0≤0 \leq i << n.

In a single operation, you can choose two indices x and y such that 0≤0 \leq x, y << n, decrement arr[x] by 11, and increment arr[y] by 11.

Return the minimum number of operations required to make all elements of arr equal.

Constraints:

  • 1≤1 \leq n ≤104\leq 10^4