classSolution: defsetZeroes(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ rows, cols = len(matrix), len(matrix[0]) first_row = Trueif0in matrix[0] elseFalse for i inrange(rows): for j inrange(cols): if matrix[i][j] == 0: if i > 0: matrix[i][0] = "S" matrix[0][j] = "S" for i inrange(1, rows): if matrix[i][0] == "S": matrix[i] = [0] * cols for j inrange(cols): if matrix[0][j] == "S": for i inrange(rows): matrix[i][j] = 0 if first_row: matrix[0] = [0] * cols