1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix
Description
Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge.
Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.
A binary matrix is a matrix with all cells equal to 0 or 1 only.
A zero matrix is a matrix with all cells equal to 0.
Example 1:

Example 2:
Example 3:
Example 4:
Constraints:
m == mat.lengthn == mat[i].length1 <= m, n <= 3mat[i][j]is either0or1.
ac
Previous1283. Find the Smallest Divisor Given a ThresholdNext1285. Find the Start and End Number of Continuous Ranges
Last updated
Was this helpful?