Slowest Restaurant to Reach From a Courier Depot
Last updated: November 29, 2026
Quick Overview
A city road graph has directed edges with travel times in minutes. Given a courier depot node, return the time needed until every restaurant node can be reached (the largest shortest-path time), or -1 if some restaurant is unreachable.
Uber
November 29, 20260
0
0 solved
A city road graph has directed edges with travel times in minutes. Given a courier depot node, return the time needed until every restaurant node can be reached (the largest shortest-path time), or -1 if some restaurant is unreachable.
A Dijkstra screen in the style of Uber's technical rounds, set in Uber Eats delivery-radius planning. The interviewer checks a correct heap-based Dijkstra, lazy deletion of stale heap entries, and the reachability check.
What the Interviewer Expects
- Builds an adjacency list from the edge list
- Uses a min-heap keyed by tentative distance
- Skips stale heap entries
- Returns -1 if any restaurant is unreachable
- States O((V + E) log V)
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
- How would you return the restaurants outside a 20 minute radius?
- What if edge times change by time of day?
- How would you serve this query for thousands of depots per second?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: n nodes labeled 0..n-1, edges as (u, v, minutes) with non-negative weights, a depot, and a list of restaurants. Output: max over restaurants of the shortest time from depot, or -1. No...
High-Level Design
Standard Dijkstra from the depot: pop the closest unsettled node, relax its outgoing edges, push improved distances. Use lazy deletion: if a popped distance is larger than the recorded best, skip it. ...