Solution: Set Matrix Zeroes
Understand how to solve the Set Matrix Zeroes problem by using the matrix's first row and column as markers to track zero elements. Explore an optimized approach that modifies the matrix in place without extra space, improving both time and space efficiency.
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