Earliest Arrival Across Freight Terminals With Opening Windows

Last updated: November 29, 2026

Quick Overview

Trucks drive an undirected road network between nodes with fixed drive times, but some nodes (terminals and handoff yards) can only be entered during listed time windows, and a truck that arrives early waits. Given a departure time, return the earliest time the truck can arrive at the destination, or -1 if impossible.

Aurora
Coding & Algorithms
Software Engineer
Aurora
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Trucks drive an undirected road network between nodes with fixed drive times, but some nodes (terminals and handoff yards) can only be entered during listed time windows, and a truck that arrives early waits. Given a departure time, return the earliest time the truck can arrive at the destination, or -1 if impossible.

Aurora's driverless lanes run hub to hub, and terminals have operating hours, so freight planning is a time-dependent shortest path problem. This onsite question checks whether you can see that Dijkstra still works when waiting is allowed (the FIFO property) and whether you can reason about why it would break otherwise.

What the Interviewer Expects
  • Models arrival time, not distance, as the Dijkstra key
  • Implements a ready_time function that waits for the next open window or rejects the node
  • Explains why earlier arrival never hurts (FIFO), which keeps Dijkstra correct
  • Handles a source that is itself closed at departure
  • Gives complexity including the window lookup
Key Topics to Cover
Time-dependent shortest path
Dijkstra
FIFO property
Time windows
Binary search
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What breaks if waiting is forbidden at intermediate nodes?
  • Drive times now depend on departure time (rush hour in Houston): what property must hold for this algorithm to stay correct?
  • How would you add a cap on total driving hours for a human-observed run?
  • How would you answer many queries with different departure times efficiently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

edges are (u, v, drive_time). windows[v] is a sorted list of disjoint (open, close) intervals; a truck may be at v only at a time inside a window, and may wait outside until it opens. Nodes ...

High-Level Design

The key insight: if you reach a node earlier, you can always wait and behave exactly as if you arrived later. So arrival time is monotone and the earliest arrival at each node is all that matters. Tha...


Submit Your Answer
Markdown supported

Related Questions