FastPrepCapacity To Ship Packages Within D Days
Problem · Array

Capacity To Ship Packages Within D Days

MediumAmazon logoAmazonFULLTIMEPHONE SCREEN
See Amazon hiring insights

Problem statement

A conveyor belt has packages that must be shipped from one port to another within days days.

The i-th package has weight weights[i]. Packages are loaded in the given order: you may not rearrange them. Each day, you load the conveyor with packages whose total weight does not exceed the ship's capacity, then ship that day's load.

The problem statement continues
Pro

Examples

Example 1

weights = [1,2,3,4,5,6,7,8,9,10]days = 5return = 15

Capacity 15 ships as [1,2,3,4,5], [6,7], [8], [9], and [10]. Capacity 14 needs more than 5 days.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week