Practice: Set Matrix Zeroes

Problem: https://leetcode.com/problems/set-matrix-zeroes/

Recognition reminder: for every zero in the matrix you must zero its whole row and column, in place. An in-place grid transform where the order of your reads and writes will matter is the math/geometry cue.

Before you start (the five-beat rhythm)

  1. Your three Pattern Cards for this week are already written.
  2. Name the pattern aloud (which of the three, and why) and write your approach as a plain-English comment before any code.
  3. Struggle floor: 25 minutes unaided. No hints, no AI, no Discuss tab.
  4. If stuck past the floor, ask the tutor for a hint. Six rungs, one per ask.
  5. Debrief in your commit message before moving to the next problem.

Your target

Fill these in yourself before you look at anyone else’s solution:

Target time complexity:  ____
Target space complexity: ____

Two passes give O(m * n) time. The straightforward marker storage is O(m + n) space; the in-place trick reuses row 0 and column 0 as markers for O(1) extra space. Either is acceptable; know exactly which one you used and why marking before zeroing is required.

In-place note

You mutate matrix directly and return None. The provided test passes in a fresh copy of each input, calls your set_zeroes, and compares the mutated matrix to the expected result, so write your function to change the argument in place (do not build and return a new matrix).

Where your code goes

Write your solution in your own work repo (see getting-started.md), not in this folder. This folder ships only the problem spec and a provided-example test (tests/test_provided.py) so you can check the given cases locally before you submit to LeetCode’s judge. The judge is the oracle; the tutor will not confirm your answer by reading it.

Debrief (paste into your commit message)

1. What pattern did this turn out to be?
2. What was the trigger phrase or input shape that should have made me reach for it?
3. What was the time and space complexity, and what would dominate at scale?
4. What edge case would have broken my first attempt?
5. What would I do differently in three days when I see this cold?