Powerful Ultimate Binary Search Template
One of the most upvoted posts on LeetCode: a single binary search template for finding the minimal value that satisfies a condition, applied to a sequence of problems from First Bad Version to hard ones such as Split Array Largest Sum and Koko Eating Bananas. It removes the usual off-by-one confusion about loop conditions and boundary updates, and shows how to recognise binary search on the answer. Code is in Python.
Guide
Interview Prep
zhijun_liao (LeetCode)
Intermediate
Free
One of the most upvoted posts on LeetCode: a single binary search template for finding the minimal value that satisfies a condition, applied to a sequence of problems from First Bad Version to hard ones such as Split Array Largest Sum and Koko Eating Bananas. It removes the usual off-by-one confusion about loop conditions and boundary updates, and shows how to recognise binary search on the answer. Code is in Python.
Ready to start?
Opens on zhijun_liao (LeetCode) in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.