Farthest Delivery Stop Reachable With Limited Fuel and Boosts
Last updated: November 29, 2026
Quick Overview
A delivery robot moves along stops with given elevations. Climbing from stop i to a higher stop i + 1 costs either the height difference in battery units or one boost charge. With a battery budget and a number of boosts, return the farthest stop index reachable.
Amazon
November 29, 20260
0
0 solved
A delivery robot moves along stops with given elevations. Climbing from stop i to a higher stop i + 1 costs either the height difference in battery units or one boost charge. With a battery budget and a number of boosts, return the farthest stop index reachable.
A greedy heap problem in the style of Amazon's onsite loops, recast as route planning for a sidewalk delivery robot. Interviewers check that you save boosts for the largest climbs by keeping a min-heap of the climbs currently covered by boosts.
What the Interviewer Expects
- Treat each upward step as a cost that must be paid
- Assign boosts to climbs tentatively and keep them in a min-heap
- When boosts run out, pay battery for the smallest boosted climb
- Stop when battery goes negative
- Explain O(n log b) 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
- How would you solve it with binary search on the answer instead?
- What if each boost covered at most a certain height?
- How would you return which climbs used boosts?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: list of elevations (length n), integer battery >= 0, integer boosts >= 0. Downhill or flat steps are free. Output: largest index reachable from index 0....
High-Level Design
Walk forward. For each climb of size d > 0, push d into a min-heap representing climbs covered by boosts. If the heap size exceeds the boost count, the smallest climb in it is the cheapest to pay with...