Roadmap › Stage 3: Binary Search › Pattern 14 of 53
DSA pattern guide

Binary Search on Answers

"Minimum possible maximum", "least speed/capacity/days so that…".

Stage 3 · Binary Search6 problems5 Medium · 1 Hard

Use it when

"Minimum possible maximum", "least speed/capacity/days so that…".

Key idea

The answer lies in a numeric range and feasibility is monotonic. Binary search the answer and write a greedy check(x).

Practice problems, in order

  1. Koko Eating BananasMedium
  2. Capacity To Ship Packages Within D DaysMedium
  3. Min Speed to Arrive on TimeMedium
  4. Min Days to Make M BouquetsMedium
  5. Magnetic Force Between Two BallsMedium
  6. Split Array Largest SumHard

How to practise this pattern

  1. Read the problem and look for the signal above before writing any code.
  2. Say the brute force out loud, with its time complexity, then ask what work it repeats.
  3. Apply the key idea and write the optimised version yourself.
  4. If you're stuck for more than 10 minutes, take one small hint, not the full solution.
  5. Move to the next problem only when you can explain why this pattern fits.

Stuck on one of these?

The AlgoSolveo extension (free, launching soon) sits beside the LeetCode problem and gives the smallest hint that gets you moving, never the full answer. Solved problems tick off on your roadmap.

Join the extension waitlistTrack it on the roadmap
← Previous patternBinary Search — ClassicNext pattern →Stack — Parenthesis