Set Matrix Zeroes
Explore how to modify a matrix in place by setting entire rows and columns to zero when a zero element is found. Learn this essential matrix operation pattern to solve coding interview questions efficiently without extra space.
We'll cover the following...
We'll cover the following...
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