Capacity To Ship Packages Within D Days, is a LeetCode problem. In this post we will see how we can solve this challenge in C++

Problem Description

Example 1:

Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5 Output: 15 Explanation: A ship capacity of 15 is the minimum to ship all the packages in 5 days like this: 1st day: 1, 2, 3, 4, 5 2nd day: 6, 7 3rd day: 8 4th day: 9 5th day: 10

Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), ( ....

You can find the full details of the problem Capacity To Ship Packages Within D Days at LeetCode

Solution: Please check the main.cpp snippet for the solution.

This solution originally posted at: Github by @kamyu104