Can a Delivery Drone Hop Across Charging Pads With Variable Jumps
Last updated: November 29, 2026
Quick Overview
Charging pads lie at sorted positions along a line starting at 0; a drone makes a first hop of exactly 1, and if its last hop was k it next hops k-1, k, or k+1 units forward. Return whether it can land on the final pad.
Amazon
November 29, 20260
0
0 solved
Charging pads lie at sorted positions along a line starting at 0; a drone makes a first hop of exactly 1, and if its last hop was k it next hops k-1, k, or k+1 units forward. Return whether it can land on the final pad.
Prime Air style framing for a classic hard DP where the state includes the last jump size. The interviewer checks that you identify (position, last hop) as the state, use hashing for sparse positions, and bound the complexity.
What the Interviewer Expects
- Identify the state as pad plus last hop length
- Map pad positions to sets of reachable hop lengths
- Propagate forward in sorted pad order
- Return early when the last pad is reached
- Bound the hop length by the number of pads to get O(n^2)
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
- Why is hop length bounded by about n?
- How would you return the actual sequence of hops?
- What if the drone can also hop backward?
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: sorted list pads of distinct non-negative integers with pads[0] == 0. Output: True if the drone can land on pads[-1]. Hops must land exactly on pads....
High-Level Design
Position alone is not enough state because what you can do next depends on the previous hop. So the DP state is (pad, last hop k).
Maintain hops[p] = set of hop lengths that can arrive at pad p. St...