Maximum Tips From Delivery Slots Without Taking Adjacent Ones
Last updated: November 29, 2026
Quick Overview
A courier is offered a sequence of back-to-back delivery slots with expected tips; taking a slot makes the next one impossible because of travel time. Return the maximum total tips the courier can collect.
Uber
November 29, 20260
0
0 solved
A courier is offered a sequence of back-to-back delivery slots with expected tips; taking a slot makes the next one impossible because of travel time. Return the maximum total tips the courier can collect.
A light Uber Eats framed DP warm-up used in phone screens to see whether you can define a state and recurrence cleanly before moving to something harder. The interviewer checks the take-or-skip recurrence and the O(1) space version.
What the Interviewer Expects
- Define the take or skip recurrence
- Handle empty and single-slot inputs
- Reduce space to two variables
- Explain why greedy by largest tip fails
- Mention how to recover the chosen slots
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 the slots form a loop (the first and last are adjacent)?
- What if taking a slot blocks the next two slots?
- Return the chosen slot indices
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: list of non-negative tips
t, one per slot in time order. - Cannot take two consecutive slots, because the courier cannot finish one drop-off and reach the next pickup in time.
- Output: max...
High-Level Design
Let best[i] be the maximum using slots 0..i. Either skip slot i (best[i - 1]) or take it (best[i - 2] + t[i]). Only the previous two values are needed, so two variables suffice. Greedy by la...