Solution: Set Matrix Zeroes
Explore the optimized solution to set matrix zeroes by modifying the matrix in place without using extra space. Learn to identify zero elements, mark first rows and columns, and efficiently update the matrix while understanding the time and space complexity involved.
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