Skip to content

Binary Search problems,
and the tell.

The data is sorted, or the answer itself is a number in a range where a check gets monotonically easier or harder. 167 problems in the catalogue carry this tag, from first-week easy to interview hard.

Free to start. Running and submitting a solution never costs credits.

How the pattern actually works.

One mechanism, and the mistake that costs people the problem.

The tell. The data is sorted, or the answer itself is a number in a range where a check gets monotonically easier or harder.

The mechanism. Keep the answer inside a range, look at the middle, and throw away the half that cannot hold it. The hard version is binary search on the answer: guess a value, ask a yes or no question about it.

What goes wrong. The loop condition and the update. lo < hi with hi = mid, or lo <= hi with hi = mid minus one, but never a mix of the two.

The ones asked most often.

By how often the catalogue records them being set, not by our opinion.

  1. Intersection of Two ArraysEasyasked at 12 companies
  2. House Robber IVMediumasked at 2 companies
  3. Sell Diminishing-Valued Colored BallsMediumasked at 2 companies
  4. Find the Safest Path in a GridMediumasked at 2 companies
  5. Find Beautiful Indices in the Given Array IMediumasked at 2 companies
  6. Count Pairs in Two ArraysMediumasked at 2 companies
  7. Maximum Points Inside the SquareMediumasked at 1 companies
  8. Maximum White Tiles Covered by a CarpetMediumasked at 1 companies
  9. Maximum Earnings From TaxiMediumasked at 1 companies
  10. Special Array IIMediumasked at 1 companies

Read it, watch it, then solve it.

The order that makes a pattern stick.

Everything in the app, in one place.

Practice, interviews and the tools, all free to start. Swipe to see the rest.

Free to start: 100 AI credits when you sign up and 100 every month. Start free in the app

About binary search problems.

Free to start, no card.

Start practising
How do I know a problem is a binary search problem?

The data is sorted, or the answer itself is a number in a range where a check gets monotonically easier or harder.

How many binary search problems should I solve?

Enough to stop needing the hint, which is usually ten to fifteen across the levels, not the whole list. The catalogue tags 167, split roughly 17 easy, 102 medium and 48 hard in the sample we show, so work up rather than across.

What goes wrong most often in binary search problems?

The loop condition and the update. lo < hi with hi = mid, or lo <= hi with hi = mid minus one, but never a mix of the two.

Is practising by pattern better than a problem sheet?

A sheet tells you what to solve. A pattern tells you why those problems sit together, which is the part that carries over to the problem you have not seen. That is why the app files every problem under its pattern.