Dsa
Graphs Bfs
Warm-up
Universal Translator Chain
In a galactic summit, attendees speak different languages. We have a list of available human translators who can translate between two specific languages. For example, if someone translates 'English' to 'Martian', they can also translate 'Martian' to 'English'. Given a list of language pairs that can be translated, find the minimum number of translators needed to translate from Language A to Language B. If no chain exists, print -1.
Example:
Input:
3
English French
French Spanish
Spanish German
English German
Output:
3
Key concepts
graphsbfsunweighted 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