Class Solution
-
- All Implemented Interfaces:
public final class Solution1072 - Flip Columns For Maximum Number of Equal Rows.
Medium
You are given an
m x nbinary matrixmatrix.You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from
0to1or vice versa).Return the maximum number of rows that have all values equal after some number of flips.
Example 1:
Input: matrix = [0,1,1,1]
Output: 1
Explanation: After flipping no values, 1 row has all values equal.
Example 2:
Input: matrix = [0,1,1,0]
Output: 2
Explanation: After flipping values in the first column, both rows have equal values.
Example 3:
Input: matrix = [0,0,0,0,0,1,1,1,0]
Output: 2
Explanation: After flipping values in the first two columns, the last two rows have equal values.
Constraints:
m == matrix.lengthn == matrix[i].length1 <= m, n <= 300matrix[i][j]is either0or1.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegermaxEqualRowsAfterFlips(Array<IntArray> matrix)-
-
Method Detail
-
maxEqualRowsAfterFlips
final Integer maxEqualRowsAfterFlips(Array<IntArray> matrix)
-
-
-
-