Question bank › Graphs Dfs
Dsa Graphs Dfs Easy

Subway Navigation

You are given a representation of subway lines as a graph, where each station is a node and each connection between stations is an edge. Write a program to determine if there exists a valid route from a starting station to a destination station using these connections. The program should return 'ROUTE FOUND' if such a path exists, otherwise return 'ROUTE NOT FOUND'. Input Format: - The first line contains two integers, N and E, representing the number of stations and number of connections. - The next E lines contain two integers each, which represent connections between two stations. - The last line contains two integers, S (start) and D (destination). Output Format: - Print 'ROUTE FOUND' if a path exists, otherwise print 'ROUTE NOT FOUND'. Example: Input: 5 5 1 2 1 3 2 4 3 4 4 5 1 5 Output: ROUTE FOUND

Key concepts

graphsdfsnavigation

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