Tap here to switch tabs
Problem
Ask
Submissions

Problem: Set Matrix Zeros

med
30 min
Understand how to modify a matrix in place by setting entire rows and columns to zero when any element is zero. Learn to solve this common coding interview problem efficiently without allocating additional space, enhancing your matrix manipulation skills and problem-solving approach.

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:

  • 11 \le mat.row, mat.col 20\le 20
  • 231-2^{31} \le mat[i][j] 2311\le 2^{31} - 1
Tap here to switch tabs
Problem
Ask
Submissions

Problem: Set Matrix Zeros

med
30 min
Understand how to modify a matrix in place by setting entire rows and columns to zero when any element is zero. Learn to solve this common coding interview problem efficiently without allocating additional space, enhancing your matrix manipulation skills and problem-solving approach.

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:

  • 11 \le mat.row, mat.col 20\le 20
  • 231-2^{31} \le mat[i][j] 2311\le 2^{31} - 1