Binary Search pattern

Minimum Shipping Capacity

Given package weights that must be shipped in their given order, find the minimum ship capacity such that all packages can be shipped within a given number of days, where each day loads consecutive packages without exceeding the capacity. Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 1011
  • Medium
  • 2 approaches

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

Binary SearchLeetCode 1011

Medium

From the first idea to the best one

  1. 01 Brute force · grow the ship one unit at a time O(n · Σ)O(1) space
  2. 02 Optimized · binary search the capacity O(n log Σ)O(1) space
Each approach plays step by step, with its time and space.

What you will learn

  • How to read Minimum Shipping Capacity and spot the binary search pattern in it
  • Brute force · grow the ship one unit at a time: O(n · Σ) time, O(1) space
  • Optimized · binary search the capacity: O(n log Σ) time, O(1) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Binary Search

See Minimum Shipping Capacity run, step by step

Sign in and this page opens on the animation, with all 11 Binary Search problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.