Topics / Binary Search
🎯
Binary Search
The O(log n) workhorse — classic, lower/upper bound, and binary search on the answer.
Why learn Binary Search?
-
Once you trust the invariant, off-by-one bugs vanish.
-
Solves an enormous range of "find smallest x such that…" problems.
-
A core pattern interviewers test almost every loop.
What you can build with Binary Search
Classic search in sorted arrays Rotated array problems Binary search on the answer space
Binary Search tutorials
3 articlesHand-written tutorials, ordered as a recommended learning path.
- 01 Binary Search A practical guide to binary search — the classic template, off-by-one traps, Python's bisect module, and the binary-search-on-answer pattern, with six worked problems.
- 02 LC 300 — LIS LeetCode 300 in detail — the O(n^2) DP, the O(n log n) patience-sorting trick with binary search, and when each one matters.
- 03 Rotated Search Solve LeetCode 33 Search in Rotated Sorted Array in O(log n) with modified binary search. Pivot detection, half-decision logic, and interview talking points.