Determine whether an array can be transformed so all elements become equal, and identify the minimum effort required under the problem's allowed operations.
Given an integer array, you may apply the operation(s) described by the problem to transform the array. Your task is to determine whether it is possible to make every element of the array equal. If it is possible, compute the minimum number of operations needed according to the allowed transformation rules.
This is an array equalization problem: you are looking for a target value that all elements can be converted to, while respecting the operation constraints and minimizing total work.
nums.nums contains at least one integer.Example 1
Input
nums = [1, 2, 3]
Output
possible = true, minOperations = 2
Explanation
A representative equalization process reaches a common value in the minimum number of allowed steps. The exact steps depend on the operation rules, but the key idea is to choose a feasible target and minimize total work.
Example 2
Input
nums = [4, 4, 4]
Output
possible = true, minOperations = 0
Explanation
All elements are already equal, so no operations are needed.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.