Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · DSA · Worked problems, in English · about 19 min to read

Play it as a journeyTutor comes with a plan

Clinic #33: Koko Eating Bananas

Pattern: Binary search on the answer · LC 875

Sorting aur Searching
Sorting aur Searching · Open board

Is the Hinglish foundations board for sorting and searching. Its fifth panel is this clinic in one picture: a row of candidate speeds, crosses on the slow ones, ticks on the fast ones, and one border between them that binary search finds.

Before you start. Sorting & Searching showed binary search on a sorted list: look at the middle item, throw away the half that cannot hold what you want, repeat, so a million items takes about twenty looks instead of a million. Everything in this clinic is that same move, with one change: the sorted list you search is not in the input at all.

Lesson 73 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • A laundromat, four bags, and a machine to buy
  • By hand: count the hours for one machine
  • The wrong first idea: divide the total by the hours
  • The second wrong idea: binary search the bags
  • The click: a yes/no test, and the line of answers it draws
  • Binary search on the answer: halving the machine sizes
  • The tell: “the minimum X such that”, and bigger never hurts
  • Solution ladder
  • The binary search walked, printed
  • The bug that hangs: lo = mid
  • Timings (measured, 2026-09-27)
  • First time in an interview: the path
  • The ladder: easy, medium, hard

Terms it explains: LC 875, up, ceiling, predicate, monotone, boundary, O(n log max pile), O(1), BEST.

Lab

Merge sort is O(n log n) and insertion sort is O(n squared). On the list you actually have, which does less work?

Open Already in order, then Exactly backwards, and watch which sort is named under Cheapest sort on this list.

Open Sorting aur searching

Review DSA