Your question is Easy to Medium Coding Practice. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
FedEx Ground loads packages in a fixed order and must ship them over a given number of days. Given the package weights and the number of available days, find the minimum truck capacity that allows all packages to be shipped within the deadline.
Packages cannot be reordered, and each day's shipment must consist of a contiguous portion of the input list. A day may contain multiple packages as long as their total weight does not exceed the truck capacity.
Implement ship_packages(weights, days), where weights is a list of positive integers representing package weights and days is a positive integer. Return the smallest integer capacity that can ship every package within days days.
def ship_packages(weights, days):