board: 1 means the lamp is on, 0 means it is off. In one move you pick any row or any column and toggle every lamp in it: lit ones go dark and dark ones light up.
Return True if some number of moves can turn every lamp off, and False otherwise.board=[[1, 0, 1], [0, 1, 0]] → True
Flip the second row to get two [1, 0, 1] rows, then flip the first and third columns.
board=[[1, 0], [0, 0]] → False
Exactly one of the four lamps is lit. Every flip changes two cells of this 2×2 square, so the number of lit lamps stays odd and can never reach zero.
board=[[1, 1, 1]] → True
Flipping the only row is enough.
board[i][j] is 0 or 1board=[[1, 0, 1], [0, 1, 0]]
True
Run checks the first 3 tests in your browser. Submit checks all 85 tests on the server, hidden ones included.