Question bank › Graphs Dfs
Dsa Graphs Dfs Easy

River Path Finder

You are given a 2D grid representing a river where '0' denotes land and '1' denotes water. Write a program that finds if there is a path from the leftmost column to the rightmost column, such that you can only move through '1's, either vertically or horizontally. Input Format: - The first line contains two integers, r (number of rows) and c (number of columns). - The next r lines contain c characters ('0' or '1'). Output Format: - Print 'YES' if there is a path; otherwise, print 'NO'. Example: Input: 4 5 10001 01010 10101 10010 Output: YES

Key concepts

graphsdfssearch

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.