Earliest Arrival on a Road Network With Signalized Intersections
Last updated: November 29, 2026
Quick Overview
Given a directed road graph with travel times and some intersections controlled by fixed-cycle traffic signals (leaving only during the green part of each cycle), find the earliest arrival time from a source to a destination for a given departure time.
Applied Intuition
November 29, 20260
0
0 solved
Given a directed road graph with travel times and some intersections controlled by fixed-cycle traffic signals (leaving only during the green part of each cycle), find the earliest arrival time from a source to a destination for a given departure time.
Simulation at Applied Intuition models traffic signals and route timing for scenario generation and planning tests. The interviewer checks Dijkstra adapted to time-dependent waiting and, crucially, the FIFO argument that makes it still correct.
What the Interviewer Expects
- Model waiting at a signal as a function of arrival time
- Compute the next green start with modular arithmetic
- Run Dijkstra on arrival times with lazy deletion
- Argue the FIFO property: arriving later never lets you leave earlier
- Handle unreachable destinations
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What breaks if waiting voluntarily could help, and how would you handle it?
- How would you add a penalty for each red light encountered?
- How would you precompute for many queries on the same map?
- How would you model signals with offsets between intersections (green waves)?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
roads are directed (u, v, seconds). signals[v] = (cycle, green): departures from v allowed when t mod cycle < green. Unsignaled nodes never wait. Waiting only happens at signals. Return earlie...
High-Level Design
Labels are arrival times. From node u at time t, the departure time is t if green, otherwise t + cycle - t mod cycle. Each edge then gives arrival = departure + w. The departure function is non-de...
Submit Your Answer
Applied Intuition Software Engineer Interview Guide
Interview process, tips, and preparation timeline