Zero the Rows and Columns
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
In a grid of numbers with m rows and n columns, whenever a cell is zero, its whole row and its whole column must become zero. Do it in place. Explain a simple version first, then one that uses only a constant amount of extra memory.
What a strong answer covers
- Why doing the work immediately corrupts the answer.
- Separating finding from zeroing, with a little extra memory.
- Storing the notes inside the grid itself to save that memory.
- The order of the final steps and the overall cost.
Common mistake: Reusing the first row and column as markers but zeroing them first, which wipes out the notes before the rest of the grid is done.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud