def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
res=[]
for i in range(len(matrix)):
for j in range(len(matrix[0])):
if matrix[i][j]==0:
res.append([i,j])
for zero in res:
for j in range(len(matrix[0])):
matrix[zero[0]][j]=0
for i in range(len(matrix)):
matrix[i][zero[1]]=0
Leetcode-73.矩阵置零(Python)
最新推荐文章于 2024-08-17 15:37:21 发布