| Random Link ¯\_(ツ)_/¯ | ||
| Aug 18, 2022 | » | Binary Search
2 min; updated Jun 6, 2026
Binary Search on a Non-Decreasing \(f: \mathbb{R} \to \mathbb{R}\)Given a number \(L\) and a non-decreasing function \(f: \mathbb{R} \to \mathbb{R}\), find the greatest \(x\) such that \(f(x) \le L\). To start, there are two numbers \(lo\) and \(hi\), such that \(f(lo) \le L < f(hi)\). Algorithm |
| May 28, 2026 | » | Two Sum
3 min; updated May 28, 2026
Problem DescriptionGiven a 1-indexed array of integers that is sorted in non-decreasing order, find
two numbers such that they add up to a Solution: Linear Scan with Binary SearchAt its core, the problem is a binary search one. Given \(a\), find \(b = t -
a\) in the right side of |
In my attempt at writing
...binary_search, I had: