Skip to main content

Binary Search Drill 12-Day

Write the lo/hi/mid template eyes-closed, recognize 'binary search on the answer' problems by their shape, and explain why your loop terminates.

By Alex Chen, Founder, InterviewChamp.AI · 12 problems · ~14h · difficulty: mixed · Last verified

  1. Day 1Binary Search(binary-search)

    The whole template lives here. Off-by-one is the entire game. Burn lo/hi/mid into muscle memory before you touch anything harder.

  2. Not strictly binary search — but the 'running minimum' habit is the same monotonic-thinking muscle. Use it as a warm-up between BS reps.

  3. Two binary searches: one for leftmost, one for rightmost. The 'bias the search to one side' trick generalizes to lower/upper bound problems.

  4. Day 4Search a 2D Matrix(binary-search)

    Flatten the matrix mentally: treat row-major indices as 1D. Or do two binary searches. Either answer works — defend your pick.

  5. Day 5Find Peak Element(binary-search)

    First problem to break the 'binary search needs a sorted array' mental model. Compare mid to mid+1 to decide direction.

  6. Binary search where you compare mid to RIGHT, not to a target. The mental model shift — 'compare to anchor, not target' — is the interview signal.

  7. Day 7Search in Rotated Sorted Array(binary-search)

    Decide which half is sorted, then check if target lives there. The branching is fiddly — write the four cases out loud before coding.

  8. Day 8Time Based Key-Value Store(binary-search)

    Binary search inside a hash map's value list. Practice the data-modeling step: 'where does the search happen?' is the whole design question.

  9. Day 9Koko Eating Bananas(binary-search)

    Binary search on the ANSWER, not an index. Once you see this shape once, you see it everywhere — name it the moment you spot it.

  10. Same shape as Koko. lo = max(weights), hi = sum(weights), then BS on capacity. Drill the 'find minimum X that satisfies a predicate' template.

  11. Bridge problem: not pure BS, but the 'find the largest valid X' instinct from Koko/capacity carries over. Use it to sharpen the predicate-thinking.

  12. Day 12Median of Two Sorted Arrays(binary-search)

    Capstone. Binary search on the partition. The hardest BS problem in the canon — if you can narrate it, you can narrate any BS variant.

Ready to drill these live?

Get the AI copilot in your ear during real interviews. Real-time transcription. Streaming answers. Post-call scorecard.

Download the desktop app →