Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
01 Matrix
Bookmark
Input
Example 1
Example 2
Corner zeros
Single zero
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
0
0
0
0
-1
0
0
0
0
queue
Zero
Unvisited
Computed
algo
master
.
io
Step:
Start: Find nearest distance to 0 for each cell using multi-source BFS
Variable
Value
dist
Matrix(3x3) [[0,0,0]...]
rows
-
cols
-
q
-
dirs
-
r
-
Variable
Value
c
-
dr
-
dc
-
nr
-
nc
-
0 / 50
Input
Example 1
Example 2
Corner zeros
Single zero
Custom
grid
=
[[0,0,0],[0,1,0],[0,0,0]]
0 / 50
0
0
0
0
-1
0
0
0
0
queue
Zero
Unvisited
Computed
algo
master
.
io
Step:
Start: Find nearest distance to 0 for each cell using multi-source BFS
Visualization
Variables