Dsa
Recursion
Hard
Maze Path Count
You are given a grid of size m x n where 0 represents a path and 1 represents an obstacle. Write a function to count all unique paths from the top-left corner (0,0) to the bottom-right corner (m-1,n-1) using only down and right moves. The function should return the total number of unique paths.
Input Format:
- The first line contains two integers m and n (the dimensions of the grid).
- The next m lines each contain n space-separated integers (0 or 1) representing the grid.
Output Format:
- An integer representing the number of unique paths from the top-left corner to the bottom-right corner.
Example:
Input:
3 3
0 0 0
0 1 0
0 0 0
Output:
2
Key concepts
recursionbacktrackinggrid
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