Minimum Time for Highway Drivers to Visit Every Pickup Point

Last updated: November 29, 2026

Quick Overview

Drivers and pickup points sit at integer positions on a straight highway. Each driver moves one unit per second and can change direction freely; drivers move in parallel. Return the minimum time T so every pickup point is visited by some driver.

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

0

0

0 solved


Drivers and pickup points sit at integer positions on a straight highway. Each driver moves one unit per second and can change direction freely; drivers move in parallel. Return the minimum time T so every pickup point is visited by some driver.

A hard Uber onsite question that combines binary search on the answer with a non-obvious greedy check. Interviewers look for the left-then-right versus right-then-left reasoning and a correct proof that each driver should take the leftmost unvisited point.

What the Interviewer Expects
  • Binary searches on T since a larger T never hurts
  • Sorts drivers and pickups and assigns pickups left to right
  • Handles the case where the leftmost unvisited point is left of the driver
  • Computes reach as the better of going left first or right first
  • Verifies with a brute force on small inputs
Key Topics to Cover
binary search on answer
greedy
two pointers
interval covering
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 if each driver has a different speed?
  • Return which driver visits which points.
  • How does it change if drivers must return to their start?
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: lists drivers and pickups of integer positions, both non-empty.
  • Output: minimum integer T.
  • A point is covered once any driver passes it....
High-Level Design

For a fixed T, sweep drivers from left to right and keep j, the leftmost uncovered pickup. The leftmost driver must cover it if it lies to the driver's left, since later drivers are even farther. If...


Submit Your Answer
Markdown supported