Practice Delivering Boxes from Storage to Ports
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Delivering Boxes from Storage to Ports
Problem Statement
Deliver boxes in their input order using one ship; boxes[i] = [port,weight]. Each loading takes a consecutive batch within both maxBoxes and maxWeight. Travel from storage to the first required port, then to each different next port while unloading in order; consecutive boxes for the current port require no additional trip. Return to storage after every batch, including the last. Return the minimum total number of trips.
Source: Delivering Boxes from Storage to Ports on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
boxes = [[1,1],[2,1],[1,1]], portsCount = 2, maxBoxes = 3, maxWeight = 3
4
# Example 2
boxes = [[1,2],[3,3],[3,1],[3,1],[2,4]], portsCount = 3, maxBoxes = 3, maxWeight = 6
6
# Example 3
boxes = [[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]], portsCount = 3, maxBoxes = 6, maxWeight = 7
6
Constraints
Related LeetCode Problems
Practice more problems similar to Delivering Boxes from Storage to Ports.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.