dsa · medium

Set Matrix Zeroes

GreyOrangeArray

If any cell is 0, set its entire row and column to 0. Return the matrix. Extra space O(1) preferred.

Arguments

**Example**

`` Input: [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]] ``

Constraints

1 <= m, n <= 200 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[[1,1,1],[1,0,1],[1,1,1]]

Expected:
[[1,0,1],[0,0,0],[1,0,1]]

Open in the Dojo editor