29/40
Part 6 of 7 · The worked exampleLearn

A worked example: the cheapest trip that arrives in time

Minimum Cost to Reach Destination in Time is on an Airbnb LeetCode tag list (1 source). In our setting, a courier crosses a city of districts numbered from 0. Roads run both ways and take whole minutes, at least one each. Every district charges a fee each time the courier is in it, the first and the last included. Find the cheapest trip from district 0 to the last district that takes at most limit minutes, or None.

The city, with minutes on each road, both ways
22103631, fee 50, fee 12, fee 13, fee 124, fee 1

The trip runs from district 0 to district 4.

The limit here is 12 minutes.

Predict

Within 12 minutes, which trip is the cheapest?

Pick an answer above to see the rest