Minimum Rider Trips When Batching Orders With a Wait Limit
Last updated: November 29, 2026
Quick Overview
Orders at a busy kitchen become ready at known minutes. A rider trip can carry at most k orders, and the first order in a trip may wait at most w minutes for the trip to leave; find the minimum number of trips needed.
Zomato
November 29, 20260
0
0 solved
Orders at a busy kitchen become ready at known minutes. A rider trip can carry at most k orders, and the first order in a trip may wait at most w minutes for the trip to leave; find the minimum number of trips needed.
Batching two or three orders from the same restaurant onto one delivery partner is a core lever for Zomato's delivery cost, but food cannot sit for long. The assessment checks whether the candidate can find and justify a greedy strategy rather than reaching for DP.
What the Interviewer Expects
- Sort orders by ready time
- Propose the greedy of starting each trip at the earliest unassigned order
- Argue correctness with an exchange argument
- Handle both the capacity k and the wait limit w
- Run in O(n log n)
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
- What changes if orders go to different customers and a trip has a maximum total route time?
- How would you return the actual batches rather than the count?
- If riders are limited to r at the restaurant, how do you minimize the maximum wait instead?
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: ready minutes for n orders, capacity k, wait limit w. A trip is a set of orders whose earliest ready time is s; every order in it must be ready by s + w, and it holds at most k. Min...
High-Level Design
Sort. The earliest unassigned order must be in some trip, and that trip's window cannot start earlier than its ready time. Greedy: open a trip at that order and pack the following orders while they ar...