You are given an integer array nums. Your objective is to make all elements in nums equal by repeatedly applying a reduction operation.
In a single operation, perform the following sequence of actions:
Find the maximum value in nums at index i. If multiple elements share the maximum value, choose any such index.
Find the largest value in nums that is strictly smaller than the maximum value.
Reduce nums[i] to this next largest value.
Return the total number of operations required to make all elements in nums equal.
Constraints:
nums.length
nums[i]
You are given an integer array nums. Your objective is to make all elements in nums equal by repeatedly applying a reduction operation.
In a single operation, perform the following sequence of actions:
Find the maximum value in nums at index i. If multiple elements share the maximum value, choose any such index.
Find the largest value in nums that is strictly smaller than the maximum value.
Reduce nums[i] to this next largest value.
Return the total number of operations required to make all elements in nums equal.
Constraints:
nums.length
nums[i]