First Bad Version — Left Boundary Binary Search
Find the first bad version using left-boundary binary search: shrink hi to mid when version is bad.
webcoderspeed.com
11 articles
Find the first bad version using left-boundary binary search: shrink hi to mid when version is bad.
Find where a target would be inserted in a sorted array using left-boundary binary search returning lo.
Find the starting and ending positions of a target in a sorted array using two separate binary searches.
Find the k closest elements to x in a sorted array by binary searching for the optimal left window boundary.
Find h-index from a sorted citations array in O(log n) using left-boundary binary search.
Count spell-potion pairs with product >= success by sorting potions and binary searching for each spell's threshold.
Find the kth missing number in a sorted array by binary searching on the number of missing elements up to each index.
Find the smallest letter in a circular sorted list that is greater than the target using left-boundary binary search.
Answer election queries for who is leading at time t by precomputing the leader at each vote and binary searching.
Implement get(key, timestamp) using binary search on stored sorted timestamps for O(log n) retrieval.
Maximize events attended by greedily attending the event with the earliest end date each day using binary search.