Modified Binary Search Cheat Sheet
Each step cuts a sorted range in half. You've found the left-most or right-most match once the two ends cross.

Unlock the full sheet below.
When to use it
- The list is sorted or the possible answers form a sorted range. Checking them one by one is too slow.
- You need the first or last position of a target.
- Either the problem asks for O(log n) or you can check any guess with a helper function.
- The list is sorted but rotated. Binary search still works once you find the half that's in order.
What's on the sheet
The sheet has a code template you can reuse for every Modified Binary Search problem. It's split into four steps so you can see which part changes from problem to problem. It also shows how to spot the pattern, how fast it runs, the mistakes people often make and the variations you'll see in interviews.
How to get it
You'll need full access for this one. You unlock it by solving 3 of this pattern's problems. Only 2 of those problems are free.
Preview the Two Pointers sample to see a finished sheet first.