AlgoScope

Binary Search on Answer

PatternintermediatePatterns

Recognize it when 'is x feasible?' is monotonic in x; binary search the answer space with one feasibility check per probe.

Decision · step 2 of 7Search on the Answer: Least ship capacity in 5 days
102132435465768✓79✓810✓9

Range 10 to 55, probe capacity 32. Pack greedily, starting a new day whenever the next package would overflow: 1+2+3+4+5+6+7 | 8+9+10, 2 days. Within 5, so 32 works and anything bigger is unnecessary: hi = 32.

Open in the player →or start at step 2

What you will see

The array being searched is the range of possible answers; each probe runs a feasibility check.

How search on the answer works →

Cost

BestO(log range * check)
AverageO(log range * check)
WorstO(log range * check)
SpaceO(1)

How you work with it here

play it through, step one change at a time, run it on your own input, predict what happens next.

Screen readers: Pattern lessons reuse the canonical algorithm's semantics and add a spoken "recognize this when" cue.

Reduced motion: Inherits the canonical algorithm's strategy.

Before this