Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Set Matrix Zeroes
Bookmark
Brute Force
Hash Sets
In-Place Markers
Input
3x3 One Zero
3x4 Edge Zeros
3x3 Center Zero
3x3 Corner Zeros
Custom
matrix
=
[[1,1,1],[1,0,1],[1,1,1]]
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
1
1
1
0
1
1
1
1
COPY MATRIX
O(m*n) space
1
0
1
0
0
0
1
0
1
COPY MATRIX
O(m*n) space
1
0
1
0
0
0
1
0
1
COPY MATRIX
O(m*n) space
1
0
1
0
0
0
1
0
1
DONE
O(m*n) space
1
0
1
0
0
0
1
0
1
algo
master
.
io
Step:
Start: Copy the matrix, then zero the row and column of each zero found in the copy
0 / 13
Input
3x3 One Zero
3x4 Edge Zeros
3x3 Center Zero
3x3 Corner Zeros
Custom
matrix
=
[[1,1,1],[1,0,1],[1,1,1]]
0 / 13
algo
master
.
io
Step:
Start: Copy the matrix, then zero the row and column of each zero found in the copy