Problem statement
Given a grid holding zeros, turn every cell in a row or column that contains a zero into a zero, in place.
No extra arrays are allowed, so the grid has to remember its own decisions.
Examples
Input[[1, 2, 3], [4, 0, 6], [7, 8, 9]]
Output[[1, 0, 3], [0, 0, 0], [7, 0, 9]]
The zero at [1][1] empties row 1 and column 1, and the four corners keep their values.
Input[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
Output[[0, 0, 0], [0, 4, 5], [0, 7, 8]]
A zero at [0][0] empties row 0 and column 0, which are the two lines doing the recording.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing