Maximize Value Loaded Onto a Delivery Drone Under a Weight Cap
Last updated: November 29, 2026
Quick Overview
A delivery drone can carry at most cap grams, and each candidate package has a weight and a priority value; each package can be loaded at most once. Return the maximum total value and the packages chosen.
Amazon
November 29, 20260
0
0 solved
A delivery drone can carry at most cap grams, and each candidate package has a weight and a priority value; each package can be loaded at most once. Return the maximum total value and the packages chosen.
Prime Air payloads are weight constrained, which makes 0/1 knapsack a natural Amazon technical screen question. The interviewer checks the 2D table, why the 0/1 constraint matters, and the reconstruction of the chosen set.
What the Interviewer Expects
- Define dp[i][c] as best value using the first i packages within capacity c
- Skip or take each package
- Reconstruct choices by comparing rows
- O(n * cap) time
- Explain the reverse loop if compressing to 1D
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 do you compress to 1D, and why must the capacity loop run downward?
- What if cap is 10^9 but values are small?
- What if packages have both weight and volume limits?
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 (weight, value) with positive integer weights and an integer cap. Output: (best_value, chosen_indices)....
High-Level Design
For package i and capacity c there are two options: skip it (dp[i-1][c]) or take it if it fits (dp[i-1][c-w] + v). Taking reads from row i-1, which enforces at most one copy of each package.
Gree...