Title: Array Game Code in Java
Given an array of integers, determine the number of moves required to make all elements equal. Each move consists of choosing all but one element and incrementing their values by 1.
Example: numbers = [3, 4, 6, 6, 3]
Choose 4 out of the 5 elements during each move and increment each of their values by one. Indexing begins at 1. It takes the following moves:
Unchanged element index
Iteration
Array [3, 4, 6, 6, [4, 5, [5, 7, 6, ; 1 [6, [7, 8, 8, 8, [8, 9, 9, 8, 8] 9, 10 _ 9, 9] [10 _ 10 _ 10 10 10]
Function Description:
Complete the function countMoves in the editor below:
countMoves has the following parameter(s):
int numbers[n]: an array of integers
Returns:
long: the minimum number of moves required
Constraints:
1 < n < 105
7s numbersli < 105