Maximize On-Time Orders for a Single Ghost Kitchen

Last updated: November 29, 2026

Quick Overview

A ghost kitchen prepares Uber Eats orders one at a time. Each order has a preparation time and a deadline, measured from now. Choose and sequence orders to maximize how many finish by their deadlines, and return that count.

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

0

0

0 solved


A ghost kitchen prepares Uber Eats orders one at a time. Each order has a preparation time and a deadline, measured from now. Choose and sequence orders to maximize how many finish by their deadlines, and return that count.

An onsite greedy problem in the style of Uber Eats merchant tooling. Strong candidates reach the Moore-Hodgson algorithm: sort by deadline, add each order, and when the schedule runs late drop the longest order so far.

What the Interviewer Expects
  • Shows earliest-deadline-first ordering is optimal for a fixed set
  • Uses a max-heap of preparation times
  • Drops the longest order when the running time exceeds the deadline
  • Explains why dropping the longest is safe
  • States O(n log n) complexity
Key Topics to Cover
Greedy
Heaps
Scheduling
Exchange argument
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 orders have different values and you maximize total value?
  • How would you handle orders that arrive over time (online)?
  • How would you return which orders are dropped so the kitchen can reroute them?
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 (prep, deadline) with positive integers. Output: maximum number of orders that can all finish on time. Dropped orders are rerouted, not done late....

High-Level Design

For any fixed set, doing it in deadline order is feasible if any order is (swap adjacent out-of-order pairs). So sort by deadline and scan, adding each order to a max-heap and to the running time t....


Submit Your Answer
Markdown supported