Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Path With Minimum Effort
Bookmark
Binary Search + BFS
Dijkstra
Input
Example 1 (ans: 2)
Example 2 (ans: 1)
Example 3 (ans: 0)
Custom
heights
=
[[1,2,2],[3,8,2],[5,3,5]]
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(2,2)
front / rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(2,0)
(1,2)
(2,1)
front
rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(0,2)
(1,1)
(2,0)
front
rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(0,1)
front / rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(2,2)
front / rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(1,2)
(2,1)
front
rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
(1,1)
(2,0)
front
rear
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
Default
Active
Visited
Checking
1
S
2
2
3
8
2
5
3
5
D
BFS queue (row, col)
Default
Active
Visited
Checking
algo
master
.
io
Step:
Grid is 3 by 3. The answer is somewhere in [0, 1000000], so binary search it.
0 / 341
Input
Example 1 (ans: 2)
Example 2 (ans: 1)
Example 3 (ans: 0)
Custom
heights
=
[[1,2,2],[3,8,2],[5,3,5]]
0 / 341
algo
master
.
io
Step:
Grid is 3 by 3. The answer is somewhere in [0, 1000000], so binary search it.