#C8261. Maze Path Finder
Maze Path Finder
Maze Path Finder
You are given a maze represented as an MxN grid. Each cell in the maze is either an open space denoted by a dot ('.') or a wall denoted by a hash ('#'). Your task is to determine if there is a valid path that starts at the top-left corner (0,0) and ends at the bottom-right corner (M-1, N-1).
A path can move one cell at a time in either the up, down, left, or right direction without moving diagonally, and cannot pass through walls.
Note: The maze may contain multiple obstacles, and if the starting cell or ending cell is blocked, then there is no valid path.
The answer should be YES
if a path exists and NO
otherwise.
Additionally, all formulas (if any) must be in LaTeX format.
inputFormat
The first line contains two integers M and N representing the number of rows and columns respectively.
The next M lines each contain a string of length N consisting only of '.' (open space) and '#' (wall) representing the maze.
For example:
4 4 .... .#.. .#.. ....
outputFormat
Output a single line containing YES
if there is a path from the top-left corner to the bottom-right corner; otherwise, output NO
.
4 4
....
.#..
.#..
....
YES