Dsa
Graphs Dfs
Warm-up
Path Exists
Given a grid represented by a 2D list, where '1' represents an open cell and '0' represents a blocked cell, determine if a path exists from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1). Your program should read the grid dimensions n and m, followed by n rows of the grid. Output 'YES' if a path exists, otherwise output 'NO'.
Example:
Input:
3 3
1 0 1
1 1 1
0 1 1
Output:
YES
Key concepts
graphsdfspathfinding
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