You are given a grid of size m $ imes$ n, and an integer x.
In one operation, you can choose any element in grid and either add x to it or subtract x from it.
A grid is considered uni value if all of its elements are equal.
Return the minimum number of operations needed to make grid uni value. If it is impossible to make all elements equal, return
Constraints:
m grid.length
n grid[i].length
m, n
m $ imes$ n
x, grid[i][j]
You are given a grid of size m $ imes$ n, and an integer x.
In one operation, you can choose any element in grid and either add x to it or subtract x from it.
A grid is considered uni value if all of its elements are equal.
Return the minimum number of operations needed to make grid uni value. If it is impossible to make all elements equal, return
Constraints:
m grid.length
n grid[i].length
m, n
m $ imes$ n
x, grid[i][j]