Coding Round | Google

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-09-28Added By Anonymous
Source: Link

Company: Google
Role: L3, L4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Interviewer mentioned there is no cycle for now at the beginning, not sure if there was a case at the end to include 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