Given a list of cargo capacities and a ship's capacity, find the total number of ways to distribute the cargo among the ship, considering that a ship can only carry containers with capacities that sum up to the ship's capacity, and no ship can carry more containers than its capacity. If such a distribution is not possible, return 0. The cargo can be distributed among the same ship or not. The cargo can exceed the ship's capacity or not.
Explanation: Step-by-step: We can distribute all containers among the same ship. The sum of capacities 1+2+3+4+5 = 15 exceeds the ship's capacity 10, but we can distribute all containers among the same ship by not using the last container.
Explanation: Step-by-step: We can distribute the containers among the same ship. The sum of capacities 1+2+3 = 6 equals the ship's capacity. We can put the last container with capacity 4 in the same ship, but we cannot put it because it exceeds the ship's capacity.
Master coding challenges related to Recursion and solve the [Backup] Galactic Cargo Distribution problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak