The supply chain manager at one of Amazon's warehouses is shipping the last container of the day. All n boxes have been loaded into the truck with their sizes represented in the array boxes. The truck may not have enough capacity to store all the boxes though, so some of the boxes may have to be unloaded. The remaining boxes must satisfy the condition max(boxes) ≤ capacity * min(boxes).
Given the array, boxes, and capacity, find the minimum number of boxes that need to be unloaded.
Complete the function getMinimumBoxes in the editor.
getMinimumBoxes has the following parameters:
- 1.
int[] boxes: an array of integers representing the sizes of the boxes - 2.
int capacity: the capacity of the truck
Returns
int: the minimum number of boxes that need to be unloaded
Examples
01 · Example 1
boxes = [1, 4, 3, 2] capacity = 2 return = 1

This satisfies the required condition. Hence the answer is 1.
Constraints
above are just partial constraints. I will add more once find reliable sourcesMore Amazon problems
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int getMinimumBoxes(int[] boxes, int capacity) {
// write your code here
}
boxes[1, 4, 3, 2]
capacity2
expected1
sign in to submit