Tap here to switch tabs
Problem
Submissions

Problem: Set Matrix Zeros

Set Matrix Zeroes transforms a matrix in place: whenever an element is zero, set every element in its row and column to zero without creating another matrix.

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:

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

Problem: Set Matrix Zeros

Set Matrix Zeroes transforms a matrix in place: whenever an element is zero, set every element in its row and column to zero without creating another matrix.

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:

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