Algorithm · Meta · Medium
Packages travel along a conveyor and must be transported between two ports no later than D days. The package at position i has weight weights[i]. On each day, packages are placed onto the ship following the sequence in weights. The total loaded weight for a day must not go beyond the ship's capacity. Determine the smallest ship capacity that allows every package to arrive within D days. Input: A non-empty integer array weights containing package weights, along with an…