AAlgoLoopSpaced repetition for LeetCode

Binary Search

Binary search repeatedly halves a sorted (or monotonic) search space, finding an answer in O(log n) instead of O(n). Beyond sorted arrays, reach for it whenever you can phrase the problem as 'find the smallest or largest value for which a condition flips from false to true.'

20 LeetCode problems solved with the Binary Search pattern. Practice them with spaced repetition so the pattern sticks.

See the full solution

The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.

Start free →