Solution: Set Matrix Zeroes
Let's solve the Set Matrix Zeroes problem using the Matrix Transformations pattern.
Statement
Given a matrix, mat
, if any element within the matrix is zero, set that row and column to zero. The performed operations should be in place, i.e., the given matrix is modified directly without allocating another matrix.
Constraints:
-
mat.row
,mat.col
-
mat[i][j]