Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Obstacle Removal to Reach Corner
Bookmark
Dijkstra
0-1 BFS
Input
Example 1
Example 2
No obstacles
All obstacles
Custom
grid
=
[[0,1,1],[1,1,0],[1,1,0]]
·
▨
▨
▨
▨
·
▨
▨
·
·
▨
▨
▨
▨
·
▨
▨
·
0
1
▨
▨
▨
·
▨
▨
·
heap
1 (0,1)
dist[0][1] = 1
→ push it
0
1
▨
1
▨
·
▨
▨
·
heap
1 (1,0)
neighbour (0, 2)
0
1
2
1
2
·
▨
▨
·
heap
1 (1,0)
2 (0,2)
2 (1,1)
neighbour (-1, 1)
0
1
2
1
2
·
2
▨
·
heap
2 (0,2)
2 (1,1)
2 (2,0)
dist[2][0] = 2
→ push it
0
1
2
1
2
2
2
▨
·
heap
2 (1,1)
2 (2,0)
2 (1,2)
dist[1][2] = 2
→ push it
0
1
2
1
2
2
2
▨
·
heap
2 (2,0)
2 (1,2)
neighbour (2, 1)
0
1
2
1
2
2
2
3
·
heap
2 (1,2)
3 (2,1)
neighbour (2, -1)
0
1
2
1
2
2
2
3
·
heap
3 (2,1)
neighbour (2, 2)
removed =
2
0
1
2
1
2
2
2
3
2
return 2
algo
master
.
io
Step:
Start: Settle cells cheapest-first across the 3x3 grid
0 / 48
Input
Example 1
Example 2
No obstacles
All obstacles
Custom
grid
=
[[0,1,1],[1,1,0],[1,1,0]]
0 / 48
algo
master
.
io
Step:
Start: Settle cells cheapest-first across the 3x3 grid