Gamified challenge · In-place markers
grid is an m × n board of light panels. Every panel holding `0` is short-circuited: it switches off (sets to 0) every panel in its row and its column. Only zeros in the original grid count; zeros you create don't spread further.
Write setZeroes(grid) that returns the board after the blackout. Aim for O(1) extra memory by doing it in place (the checker only looks at the result). Example: [[1, 1, 1], [1, 0, 1], [1, 1, 1]] → [[1, 0, 1], [0, 0, 0], [1, 0, 1]]. An empty grid [] stays [].
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google