Question bank › Graphs Dfs
Dsa Graphs Dfs Easy

Maze Escape

You are in a maze represented by a 2D grid. The maze is formed of '1's (walls) and '0's (paths). Write a program that finds a path from the top-left corner to the bottom-right corner of the maze, and prints the path taken as a series of coordinates. If no path exists, print 'No path exists'. Valid moves are up, down, left, and right. Input Format: - The first line contains two integers, rows and columns. - The next rows lines will contain the maze representation. Output Format: - Print the coordinates of the path if it exists, otherwise print 'No path exists'. Example: Input: 4 4 0001 1110 0000 1111 Output: (0, 0) -> (0, 1) -> (1, 1) -> (2, 1) -> (2, 2) -> (2, 3) -> (3, 3)

Key concepts

graphsdfspathfinding

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.