Code Room
CodingMediumcod-g657
Subject In place transformsLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given an m x n integer matrix, if an element is 0, set its entire row and column to 0, in place. You must use O(1) extra space (no separate m+n marker arrays): use the first row and first column themselves as markers, tracking separately whether the first row and first column originally contained a zero. Return the modified matrix.

Implement
set_zeroes(matrix: list[list[int]]) → list[list[int]]
Examples
in[[[1,1,1],[1,0,1],[1,1,1]]]out[[1,0,1],[0,0,0],[1,0,1]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.