Binary Search on Answer — definition.
Definition
When a predicate is monotonic over the answer space, binary search the answer itself.
Complexity
Time O(log R · feasibility(n)) where R is the answer range.
When to use it
- "Minimum X such that ..." or "maximum X such that ..." phrasing.
- Feasibility check is O(n) or better.
- Answer space is an integer or bounded range.
Representative scenarios
- Bandwidth Throttle — minimum capacity that ships in D days.
- Hiker's Ridge — minimum split size with k chunks.
- Deadline Bake — minimum oven temperature meeting constraint.
Related patterns
Read the full pattern page: Binary Search on Answer — template, code, and drills.
Run the free diagnostic.
Ten-minute patterns quiz. No card. Personalized loop starts on the other side.