How Far Can a Delivery Drone Climb With Batteries and Boosts
Last updated: November 29, 2026
Quick Overview
A drone flies past buildings of given heights left to right. Climbing up by d costs d battery units, or one boost covers any single climb. Given battery units and boosts, return the furthest building index reachable.
0
0
0 solved
A drone flies past buildings of given heights left to right. Climbing up by d costs d battery units, or one boost covers any single climb. Given battery units and boosts, return the furthest building index reachable.
A Google onsite greedy question placed in a Wing-style drone delivery story. The interviewer wants the insight that boosts should cover the largest climbs, maintained with a min-heap of climbs currently assigned to boosts.
What the Interviewer Expects
- Only upward steps cost anything
- Assigns boosts to the largest climbs seen so far
- Uses a min-heap of size equal to the boost count
- Pays battery for the smallest climb evicted from the heap
- Stops at the first unaffordable step
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
- Return which climbs used boosts
- What if boosts have different strengths?
- Answer many queries with different battery amounts
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: heights list, integer
battery >= 0, integerboosts >= 0. - Moving from i to i+1 is free if
h[i+1] <= h[i]; otherwise costs the climbdin battery, or one boost. - Output: the largest ...
High-Level Design
Boosts are most valuable on the biggest climbs, but we see climbs one at a time. So tentatively give every climb a boost by pushing it into a min-heap. When the heap holds more climbs than we have boo...