题目:
题解:
func setZeroes(matrix [][]int) {n, m := len(matrix), len(matrix[0])col0 := falsefor _, r := range matrix {if r[0] == 0 {col0 = true}for j := 1; j < m; j++ {if r[j] == 0 {r[0] = 0matrix[0][j] = 0}}}for i := n - 1; i >= 0; i-- {for j := 1; j < m; j++ {if matrix[i][0] == 0 || matrix[0][j] == 0 {matrix[i][j] = 0}}if col0 {matrix[i][0] = 0}}
}