Coding Round | Google

Anonymous User
1576
Sep 28, 2025
Sep 28, 2025

Interviewer mentioned there is no cycle for now at the begining not sure if there was a case at the end to inclue cycle as I couldn't solve the DAG part optimally

Good Luck!

You are given a starting city and an unordered list of trips for a customer, you are tasked with creating an itinerary for that customer. Trips are presented as pairs consisting of start and destination city names.
All cities must be used to produce the itinerary. If this is not possible return null.

Example 1:
Unordered list:

[["Amsterdam", "London"], ["Berlin", "Amsterdam"], ["Barcelona", "Berlin"], ["London", "Milan"]]

Starting:

"Barcelona"

Result:

["Barcelona", "Berlin", "Amsterdam", "London", "Milan"]

Comments (9)