Class Solution
-
- All Implemented Interfaces:
public final class Solution3240 - Minimum Number of Flips to Make Binary Grid Palindromic II\.
Medium
You are given an
m x nbinary matrixgrid.A row or column is considered palindromic if its values read the same forward and backward.
You can flip any number of cells in
gridfrom0to1, or from1to0.Return the minimum number of cells that need to be flipped to make all rows and columns palindromic , and the total number of
1's ingriddivisible by4.Example 1:
Input: grid = \[\[1,0,0],0,1,0,0,0,1]
Output: 3
Explanation:
Example 2:
Input: grid = \[\[0,1],0,1,0,0]
Output: 2
Explanation:
Example 3:
Input: grid = \[\[1],1]
Output: 2
Explanation:
Constraints:
m == grid.lengthn == grid[i].length<code>1 <= m * n <= 2 * 10<sup>5</sup></code>
0 <= grid[i][j] <= 1
-
-
Constructor Summary
Constructors Constructor Description Solution()
-