Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Rotting Oranges
Bookmark
Input
Example 1
Example 2 (impossible)
Single row
Multi-source BFS
Custom
grid
=
[[2,1,1],[1,1,0],[0,1,1]]
2
1
1
1
1
0
0
1
1
queue
Fresh
Rotten
algo
master
.
io
Step:
Start: Spread rot from all initially rotten oranges
Variable
Value
grid
Matrix(3x3) [[2,1,1]...]
rows
-
cols
-
q
-
fresh
-
dirs
-
minutes
-
Variable
Value
r
-
c
-
dr
-
dc
-
nr
-
nc
-
0 / 45
Input
Example 1
Example 2 (impossible)
Single row
Multi-source BFS
Custom
grid
=
[[2,1,1],[1,1,0],[0,1,1]]
0 / 45
2
1
1
1
1
0
0
1
1
queue
Fresh
Rotten
algo
master
.
io
Step:
Start: Spread rot from all initially rotten oranges
Visualization
Variables