Problem · Array
Minimum Total Packaging Effort
Learn this problemProblem statement
Amazon operates multiple fulfillment centers. Each center follows a special packaging rule.
You are given:
- An integer list
packEffortof sizemwherepackEffort[i]is the packaging effort required for the i-th item. - An integer list
packageCountof sizenwherepackageCount[i]indicates that at the i-th fulfillment center, if you pay to package at leastpackageCount[i]items, you get 2 extra items for free. The 2 bonus (free) items must each have a packaging effort less than or equal to the smallest effort among the paid items at that center.
You can use any fulfillment center once or not at all.
Return the minimum total packaging effort required to package all m items using any number of fulfillment centers.
Function
minTotalPackagingEffort(packEffort: List<Integer>, packageCount: List<Integer>) → intExamples
Example 1
packEffort = [50, 50, 30, 50, 20]packageCount = [2, 3]return = 120Choose the fulfillment center with packageCount = 2.
Pay for 2 items with cost 50 each → min = 50
Take 2 items for free with effort ≤ 50 → pick 30 and 50
Remaining item is 20 → pay for it
Total effort: 50 + 50 + 20 = 120
Constraints
1 ≤ n ≤ 10^51 ≤ m ≤ 10^50 ≤ packEffort[i] ≤ 10^4- Each item must be packaged exactly once.
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026