Question bank › Graphs Bfs
Dsa Graphs Bfs Warm-up

Smart Home Hub Relay

In a smart home, several IoT devices are connected in a mesh network. A signal starts at the 'Hub' and needs to reach a 'Smart Light'. Each connection between two devices counts as one 'jump'. You are given the total number of devices N (numbered 0 to N-1), a list of bidirectional connections, the ID of the Hub, and the ID of the Smart Light. Find the minimum number of jumps required for the signal to reach the light. If the light is unreachable, print -1. Example: Input: 4 3 0 1 1 2 2 3 0 3 Output: 3 (Path: 0 -> 1 -> 2 -> 3)

Key concepts

graphsbfsshortest path

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.