Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make All Grid Elements Equal

Try to solve the Minimum Operations to Make All Grid Elements Equal problem.

Statement

You are given an m×nm \times n integer matrix grid and an integer k.

In one operation, you can choose any k×kk \times k submatrix of grid and increment every element in that submatrix by 11.

Return the minimum number of operations required to make all elements in grid equal.

Constraints:

  • 1≤m==1 \leq m == grid.length ≤1000\leq 1000

  • 1≤n==1 \leq n == grid[i].length ≤1000\leq 1000

  • −105≤-10^5 \leq grid[i][j] ≤105\leq 10^5

  • 1≤1 \leq k ≤min⁡(m,n)\leq \min(m, n)

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make All Grid Elements Equal

Try to solve the Minimum Operations to Make All Grid Elements Equal problem.

Statement

You are given an m×nm \times n integer matrix grid and an integer k.

In one operation, you can choose any k×kk \times k submatrix of grid and increment every element in that submatrix by 11.

Return the minimum number of operations required to make all elements in grid equal.

Constraints:

  • 1≤m==1 \leq m == grid.length ≤1000\leq 1000

  • 1≤n==1 \leq n == grid[i].length ≤1000\leq 1000

  • −105≤-10^5 \leq grid[i][j] ≤105\leq 10^5

  • 1≤1 \leq k ≤min⁡(m,n)\leq \min(m, n)