Want to pass the matrix to the following code matrix = [[1,1,1],[1,0,1],[1,1,1]]
and print the output (to debug and understand well) just want to know where to pass and print the matrix
class Solution(object):
def setZeroes(self, matrix):
col0 = False
R = len(matrix)
C = len(matrix[0])
for i in range(R):
if matrix[i][0] == 0:
col0 = True
for j in range(1, C):
# If an element is zero, we set the first element of the corresponding row and column to 0
if matrix[i][j] == 0:
matrix[0][j] = 0
matrix[i][0] = 0
# Iterate over the array once again and using the first row and first column, update the elements.
for i in range(1, R):
for j in range(1, C):
if not matrix[i][0] or not matrix[0][j]:
matrix[i][j] = 0
# See if the first row needs to be set to zero as well
if matrix[0][0] == 0:
for j in range(C):
matrix[0][j] = 0
# See if the first column needs to be set to zero as well
if col0:
for i in range(R):
matrix[i][0] = 0