java.lang.Object
g0801_0900.s0861_score_after_flipping_matrix.Solution

public class Solution extends Object
861 - Score After Flipping Matrix.<p>Medium</p> <p>You are given an <code>m x n</code> binary matrix <code>grid</code>.</p> <p>A <strong>move</strong> consists of choosing any row or column and toggling each value in that row or column (i.e., changing all <code>0</code>&rsquo;s to <code>1</code>&rsquo;s, and all <code>1</code>&rsquo;s to <code>0</code>&rsquo;s).</p> <p>Every row of the matrix is interpreted as a binary number, and the <strong>score</strong> of the matrix is the sum of these numbers.</p> <p>Return <em>the highest possible <strong>score</strong> after making any number of <strong>moves</strong> (including zero moves)</em>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/07/23/lc-toogle1.jpg" alt="" /></p> <p><strong>Input:</strong> grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]]</p> <p><strong>Output:</strong> 39</p> <p><strong>Explanation:</strong> 0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> grid = [[0]]</p> <p><strong>Output:</strong> 1</p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == grid.length</code></li> <li><code>n == grid[i].length</code></li> <li><code>1 <= m, n <= 20</code></li> <li><code>grid[i][j]</code> is either <code>0</code> or <code>1</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • matrixScore

      public int matrixScore(int[][] grid)