Question bank › Stack
Dsa Stack Hard

Escape Maze with Backtrack

You are given a 2D maze where '0' represents a walkable path and '1' represents walls. You start from the top-left corner (0,0) and can only move right or down. Your task is to determine if there is a path to the bottom-right corner (n-1,m-1). Write a program that reads the maze and prints 'YES' if a path exists and 'NO' otherwise. Input format: - The first line contains two integers n (rows) and m (columns). - The next n lines each contain m binary integers (0 or 1) representing the maze. Output format: - A single line containing 'YES' or 'NO'. Example: Input: 3 3 0 0 1 1 0 0 0 0 0 Output: YES

Key concepts

stackbacktrackingmaze

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