Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Capacity To Ship Packages Within D Days

Medium

Topics
ArrayBinary Search

Package weights nums must be shipped in order within target days. Each day loads a contiguous prefix whose total weight is at most the ship capacity. Return the minimum capacity that ships everything within target days.

Example 1

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

Example 2

Input:  weights = [3,2,2,4,1,4], days = 3
Output: 6

Constraints

  • 1 <= nums.length <= 5*10^4
  • 1 <= target <= nums.length
  • 1 <= nums[i] <= 500
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access