Dsa
Matrix
Medium
Unique Paths in Matrix
Given a m x n grid, where each cell can either be empty (0) or blocked (1), calculate the number of unique paths from the top-left corner to the bottom-right corner. You can only move right or down.
Input Format:
The first line contains two integers m and n. The next m lines each contain n space-separated integers (0 or 1).
Output Format:
Print the total number of unique paths.
Example:
Input:
3 3
0 0 0
0 1 0
0 0 0
Output:
2
Key concepts
matrixpathfindingdp
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