Score After Flipping Matrix
MediumGreedy
Decode it first. Clues, constraints, pattern and plan before any code.grid is an m x n matrix of 0s and 1s. A move toggles every cell in one row or one column (0 becomes 1, 1 becomes 0). After any number of moves, read each row as a binary number and add them up. Return the highest possible score.
grid = [[0, 0, 1, 1],
[1, 0, 1, 0],
[1, 1, 0, 0]] → 39 (1111 + 1001 + 1111 = 15 + 9 + 15)Constraints
m == grid.lengthn == grid[i].length1 <= m, n <= 20grid[i][j]is0or1.