# Binary Search

> LeetCode #792 — Binary Search. Solve on LeetCode, then implement here if you want it in your drill queue.

https://leetcode.com/problems/binary-search/

Canonical: https://learn.significanthobbies.com/curriculum/drills/lc-binary-search

LeetCode #792 — Binary Search. Solve on LeetCode, then implement here if you want it in your drill queue.

https://leetcode.com/problems/binary-search/

## The mechanism

Binary search is not about sorted arrays — it is about a monotonic predicate. If you can phrase the answer as "the smallest x for which condition(x) is true", you can binary-search the answer space, halving it each step.

## Expected evidence

Pass all LeetCode test cases for this problem.

## Hints

- Pattern hint: binary search.
- Start with brute force, then optimize time/space.
- Write down invariants before coding.

## Sources and practice

- [Binary search algorithm (Wikipedia)](https://en.wikipedia.org/wiki/Binary_search_algorithm)
- [Study Binary Search](https://learn.significanthobbies.com/curriculum/concepts/binary-search)
- [Try the interactive drill](https://learn.significanthobbies.com/drills/lc-binary-search)
- [All practice briefs](https://learn.significanthobbies.com/curriculum/drills/)
