grid of zeros and ones. A row or column is a mirror line if it reads the same in both directions.
One flip changes any single cell to the opposite value. Return the minimum number of flips after which **either every row** or **every column** is a mirror line.grid=[[1, 1, 0], [0, 0, 1], [1, 0, 1]] → 2
Making every row a palindrome takes 2 flips (in the first two rows); the columns would also need 2, so the answer is 2.
grid=[[0, 1, 1, 0], [1, 1, 0, 0]] → 2
Rows need 2 flips (the second row), columns need 2 too (two columns differ top and bottom). The minimum is 2.
grid=[[1], [0], [0]] → 0
Each one-cell row already reads the same both ways.
grid=[[1, 1, 0], [0, 0, 1], [1, 0, 1]]
2
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.