题目:
题解:
class Solution:def setZeroes(self, matrix: List[List[int]]) -> None:m, n = len(matrix), len(matrix[0])flag_col0 = Falsefor i in range(m):if matrix[i][0] == 0:flag_col0 = Truefor j in range(1, n):if matrix[i][j] == 0:matrix[i][0] = matrix[0][j] = 0for i in range(m - 1, -1, -1):for j in range(1, n):if matrix[i][0] == 0 or matrix[0][j] == 0:matrix[i][j] = 0if flag_col0:matrix[i][0] = 0