Capacity To Ship Packages Within D Days

A conveyor belt has packages that must be shipped from one port to another within a given number of days. Each package has a specified weight. Every day, the ship is loaded with packages in the order given, but not exceeding the ship's maximum weight capacity. The objective is to determine the minimum ship capacity needed so that all packages are shipped within the given number of days.

Constraints

  • 1 <= days <= weights.length <= 5 * 10^4
  • 1 <= weights[i] <= 500
Saving… · 3 lines
class Solution:
def shipWithinDays(self, weights, days):
pass
Console

Click Run to execute sample tests.