For the best experience, increase the window size or view on a laptop or desktop device
Last updated: Pending
Title | ||
|---|---|---|
Loading... | ||
1/1
No questions are available yet
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
Given a 2D grid maze representing a maze, where:
0 = Empty space (walkable)1 = Wall (impassable)6 = Monster (walkable, but consumes 1 life)A character starts at (si, sj) and aims to reach (ei, ej). The character has N lives. Find the shortest path from the start to the end, considering the character can walk over at most N-1 monsters.
Constraints:
-1 if no path exists.Example:
maze = [
[0, 0, 1, 0],
[6, 0, 0, 0],
[0, 1, 6, 0],
[0, 0, 0, 0]
]
si, sj = 0, 0
ei, ej = 3, 3
N = 2
# Expected Output: 7
Given a 2D grid maze representing a maze, where:
0 = Empty space (walkable)1 = Wall (impassable)6 = Monster (walkable, but consumes 1 life)A character starts at (si, sj) and aims to reach (ei, ej). The character has N lives. Find the shortest path from the start to the end, considering the character can walk over at most N-1 monsters.
Constraints:
-1 if no path exists.Example:
maze = [
[0, 0, 1, 0],
[6, 0, 0, 0],
[0, 1, 6, 0],
[0, 0, 0, 0]
]
si, sj = 0, 0
ei, ej = 3, 3
N = 2
# Expected Output: 7
Output