Amazon | SDE II | Onsite Coding Question
Anonymous User
4765

We are given N solar systems, each solar system with M planets. We can move to any other planet of the same solar system in 1 light year.We can move from Mth planet of Kth solar system to 1st planet of (K + 1)th solar system in 1 light year. Apart from this we are also given a list of wormholes, where each wormhole specifies the entry planet and exit planet. Passing through a wormhole would also take 1 light year.
Now given the X-starting planet, and Y-destination planet, we need to find the minimum number of light-years that we would take to travel.

Comments (6)