Set matrix zeros in place

Write codeMedium25 minMicrosoft and Amazon style

Your task

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.

Examples

set_zeroes(matrix: list[list[int]]) -> list[list[int]]
Example 1
Inputset_zeroes([[1, 1, 1], [1, 0, 1], [1, 1, 1]])
Output[[1, 0, 1], [0, 0, 0], [1, 0, 1]]