DEV Community

Discussion on: Solution: Minimize Deviation in Array

theyousssef profile image
Youssef Mohamed

shouldn't the 3rd example in the question be 1 ? as the array will be [4,5,4]

seanpgallivan profile image
seanpgallivan Author

Unfortunately, the only operation available for even numbers is to divide by two, so you wouldn't be able to multiply the first element 2 by two to get 4.

That makes the optimal result [2,5,4] or [2,5,2].