Set Matrix Zeroes
2D Arrays (Matrices) DSA practice problem on Onlearn.
Difficulty: medium.
Topics: Set Matrix Zeroes: If an element in a matrix is 0, set its entire row and column to 0, Arrays, Matrices, Two-dimensional Array Traversal, In-place Algorithm, Time Complexity, Space Complexity, Big O Notation, Loops, in-place algorithms, space complexity, auxiliary data structures, matrix manipulation, time complexity analysis, Matrix Manipulation, Auxiliary Data Structures.
Set Matrix Zeroes Problem Statement Given an m x n integer matrix, if an element is 0, set its entire row and column to 0s. You must do this in place. Examples Example 1: Explanation: Since matrix[1][1] is 0, the 2nd row and 2nd column (0 indexed) are set to 0. Example 2: Explanation: Since matrix[0][0] is 0 and matrix[0][3] is 0, the 1st row, 1st column, and 4th column (0 indexed) are set to 0.