Imagine you have a binary matrix (containing only 0s and 1s) and you possess a magical power: you can flip entire columns at will! When you flip a column, every 0 becomes a 1 and every 1 becomes a 0 in that column.
Your goal is to strategically choose which columns to flip so that you maximize the number of rows that become uniform (all 0s or all 1s). Think of it as organizing a binary pattern to create the most harmony possible!
Input: An m ร n binary matrix
Output: The maximum number of rows that can be made uniform after optimally flipping columns
Example: If you have matrix [[0,1],[1,1]], you can flip column 0 to get [[1,1],[0,1]], making the first row uniform. The answer would be 1.
Input & Output
Constraints
- m == matrix.length
- n == matrix[i].length
- 1 โค m, n โค 300
- matrix[i][j] is either 0 or 1