Schedule Courier Pickups With Per-Restaurant Cooldown Gaps

Last updated: November 29, 2026

Quick Overview

Each character in a list is a pickup at a restaurant. A courier completes one pickup or idles per minute, and two pickups at the same restaurant must be at least n minutes apart. Return the minimum minutes to finish all pickups.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each character in a list is a pickup at a restaurant. A courier completes one pickup or idles per minute, and two pickups at the same restaurant must be at least n minutes apart. Return the minimum minutes to finish all pickups.

A technical screen problem with an Uber Eats framing about spreading out orders at busy restaurants. It tests greedy scheduling with a heap and, for strong candidates, the closed-form count.

What the Interviewer Expects
  • Always schedules the restaurant with the most remaining pickups that is not cooling down
  • Uses a max-heap of remaining counts and a queue for cooling restaurants
  • Counts idle minutes correctly when nothing is available
  • Derives the formula (max_count - 1) * (n + 1) + ties
  • States O(T log 26) or O(T) time
Key Topics to Cover
heaps
greedy
scheduling
counting
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
  • Return an actual schedule, not just its length.
  • What if each restaurant has its own cooldown?
  • How would you rearrange so no two identical pickups are adjacent, or report it is impossible?
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: list of restaurant labels, cooldown n >= 0.
  • Output: minimum total minutes including idle minutes.
  • Order of pickups can be chosen freely....
High-Level Design

Greedy: each minute, run the available restaurant with the most remaining pickups, since the most frequent one is what forces idle time. Keep a max-heap of remaining counts. After using a restaurant, ...


Submit Your Answer
Markdown supported