Dsa
Recursion
Medium
Path to Target In Matrix
You are given a 2D grid of integers where some cells are obstacles (denoted by -1) and others are free path (denoted by 0). You need to find if there is a path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1) of the grid. You can only move right or down. Output 'YES' if such a path exists and 'NO' otherwise.
Example Input:
3 3
0 0 0
0 -1 0
0 0 0
Example Output:
YES
Key concepts
recursionbacktrackingmatrices
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