Dsa
Graphs Dfs
Easy
Maze Solver
You are given a maze represented by a grid of '0' (empty space), '1' (walls), 'S' (start), and 'E' (end). Your task is to determine if there is a path from 'S' to 'E' using DFS. You can move left, right, up, or down.
Input:
First line contains two integers m (rows) and n (columns).
Following m lines are composed of '0', '1', 'S', and 'E'.
Output:
Print 'Path Exists' if there is a path from 'S' to 'E', otherwise 'No Path'.
Example:
Input:
3 3
0 1 0
S 0 0
0 1 E
Output:
Path Exists
Key concepts
graphsdfsmaze
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now