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
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
Dijkstra
Shortest paths
Heaps
Weighted graphs
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
  • 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 Problems
Sample 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. ...


Submit Your Answer
Markdown supported

Related Questions