用了set来投机取巧
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
m = len(matrix)
n = len(matrix[0])
cm = set()
cn = set()
for i in range(m):
for j in range(n):
if matrix[i][j] == 0:
cm.add(i)
cn.add(j)
for i in cm:
for j in range(n):
matrix[i][j] = 0
for j in cn:
for i in range(m):
matrix[i][j] = 0