Binary-Search
LeetCode 278: First Bad Version
·1 min
LeetCode
Easy
Binary-Search
Interactive
LeetCode 278 note: find the first version where isBadVersion is True with a lower-bound binary search, calling the API O(log n) times
LeetCode 268: Missing Number
·1 min
LeetCode
Easy
Array
Hash-Table
Math
Binary-Search
LeetCode 268 note: the sum of 0..n minus the array’s sum is the missing number, which may be 0
LeetCode 69: Sqrt(x)
·1 min
LeetCode
Easy
Math
Binary-Search
Newtons-Method
LeetCode 69 note: find the largest mid with mid² <= x; when a closed-interval search ends, r is the answer
LeetCode 35: Search Insert Position
·2 mins
LeetCode
Easy
Array
Binary-Search
LeetCode 35 note: find the first position >= target (lower bound); a half-open [l, r) needs r = mid, not r = mid - 1