Most Short Deliveries a Courier Can Finish Before Shift End
Last updated: November 29, 2026
Quick Overview
A courier has a shift of L minutes and a list of available delivery jobs with known durations. Jobs are done one at a time and any subset can be chosen. Return the maximum number of jobs the courier can finish within the shift.
Uber
November 29, 20260
0
0 solved
A courier has a shift of L minutes and a list of available delivery jobs with known durations. Jobs are done one at a time and any subset can be chosen. Return the maximum number of jobs the courier can finish within the shift.
An Online Assessment style greedy problem set in Uber Eats courier planning. The grader wants the shortest-first insight and a one-line exchange argument for why it is optimal.
What the Interviewer Expects
- Sorts durations ascending
- Stops as soon as the next job does not fit
- Justifies the greedy with an exchange argument
- Handles zero-length shifts and empty job lists
- States O(n log n) time
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 if each job also pays a different amount and you maximize earnings?
- What if jobs have release times and cannot start early?
- How would you answer many queries for different shift lengths quickly?
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: L >= 0 and a list of positive integer durations. Output: the largest count k such that some k jobs have total duration at most L. Order of doing jobs does not matter since only the total time...
High-Level Design
Take jobs from shortest to longest until the next one would overflow the shift. Exchange argument: if an optimal set of size k skips a shorter job in favour of a longer one, swapping them keeps the to...