This question evaluates competency in grid-based pathfinding, graph modeling, and algorithmic complexity analysis for computing shortest paths in discrete spaces.
You are given a grid-based maze game.
R x C
grid of characters:
'#'
= wall (cannot pass)
'.'
= empty cell
'S'
= current player position (exactly one)
'E'
= exit/goal (exactly one)
S
to
E
, moving 4-directionally (up/down/left/right) and not passing through walls.
E
is unreachable, return
-1
.
Write a function that takes the maze grid and returns the score.
Clarify in your solution:
(startRow, startCol)
instead of embedding
'S'
in the grid.