Make equal elements Array
Last updated
Last updated
Time Complexity: โ
Space Complexity: โ
Each column represents: no change, add x
and subtract x
in order for the top to bottom
Observe that 5 is present in each column
That is to say, 5 can be formed by either adding or subtracting or by doing nothing
Also notice that 5 is the average of the whole array
Thus we need to find the average and check if: each digit is already equal to the average or if it can be made equal to the average by adding or subtracting x