73 Set Matrix Zeroes
class Solution:
def setZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
row_s = len(matrix)
col_s = len(matrix[0])
set_r = set()
set_c = set()
for i in range(row_s):
for j in range(col_s):
if (matrix[i][j] == 0):
set_r.add(i)
set_c.add(j)
j = 0
# zero out the rows
for r in set_r:
matrix[r] = [0] * col_s
# zero out the cols
for c in set_c:
for iter in range(0, row_s):
matrix[iter][c] = 0Last updated