Doordash Phone Screen
Anonymous User
525

You are given a list of locations connected by roads, each with a designated beauty value and travel time. Starting at location 0 (the source), your goal is to traverse to various locations, collecting beauty values along the way. You have a maximum time limit (max_time) to complete your route, which includes the time required to return to the source location (0).
Each not beauty value can only be consider once along the route
Example:

Locations: 0, 1, 2, 3
Beauty values: 5, 10, 10, 20
Travel times: 0, 10, 10, 10
Connections: (0, 1), (0, 2), (2, 3)
max_time: 60
return value should be 45

I failed the intreview , was not handling case to return back to 0 with the timing consideration. Not sure how to maintain visited set with timing constraint

Comments (6)