Tap here to switch tabs
Problem
Submissions

Problem: Minimum Flips to Make Binary Grid Palindromic II

Try to solve the Minimum Flips to Make Binary Grid Palindromic II problem.

Statement

You are given an mimesnm imes n binary matrix grid.

A row is considered palindromic if it reads the same from left to right as it does from right to left. Similarly, a column is considered palindromic if it reads the same from top to bottom as it does from bottom to top.

A matrix is considered palindromic if every row is palindromic, every column is palindromic, and the total number of 11’s in the matrix is divisible by 44.

In one operation, you can flip any element in grid from 00 to 11 or from 11 to 00.

Return the minimum number of flips required to make grid palindromic.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤mimesn≤2imes1051 \leq m imes n \leq 2 imes 10^5

  • 0≤0 \leq grid[i][j] ≤1\leq 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Flips to Make Binary Grid Palindromic II

Try to solve the Minimum Flips to Make Binary Grid Palindromic II problem.

Statement

You are given an mimesnm imes n binary matrix grid.

A row is considered palindromic if it reads the same from left to right as it does from right to left. Similarly, a column is considered palindromic if it reads the same from top to bottom as it does from bottom to top.

A matrix is considered palindromic if every row is palindromic, every column is palindromic, and the total number of 11’s in the matrix is divisible by 44.

In one operation, you can flip any element in grid from 00 to 11 or from 11 to 00.

Return the minimum number of flips required to make grid palindromic.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤mimesn≤2imes1051 \leq m imes n \leq 2 imes 10^5

  • 0≤0 \leq grid[i][j] ≤1\leq 1