Question bank › Recursion
Dsa Recursion Medium

Pathfinding in a Maze

You are given a two-dimensional grid of 0s and 1s, where 0s represent open paths and 1s represent walls. Write a function to find all unique paths from the top-left corner to the bottom-right corner of the grid. You can move right, down, left, or up, but not diagonally. Paths should not revisit the same cell in one traversal. Input format: - The first line contains two integers m and n (1 <= m, n <= 10), the dimensions of the grid. - The next m lines each contain n integers (0 or 1) representing the grid. Output format: - Print each unique path as a list of coordinates on a new line. Example: Input: 3 3 0 0 1 0 0 0 1 0 0 Output: [(0, 0), (0, 1), (1, 1), (2, 1), (2, 2)] [(0, 0), (1, 0), (1, 1), (2, 1), (2, 2)]

Key concepts

recursionbacktrackinggrid traversal

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.