When to use it
Reach for Lower/upper bound when a binary search problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Pattern
Lower/upper bound is a reusable approach under Binary Search. Once you recognize the shape of the input and the ask, this pattern gives you a standard plan instead of inventing a new algorithm from scratch.
Reach for Lower/upper bound when a binary search problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Reference implementation in C#, Python, Java, JavaScript, and C++.
Interviewers grade pattern recognition. Naming Lower/upper bound early shows you can classify the problem inside Patterns.
Drill Lower/upper bound with Binary Search problems — filter the bank and solve 2–3 Easy/Medium items while saying the invariant out loud.
Related Binary Search problems — open any one and apply Lower/upper bound.
Median of Two Sorted Arrays
Binary Search
Search in Rotated Sorted Array
Binary Search
Find First and Last Position of Element in Sorted Array
Binary Search
Search Insert Position
Binary Search
Search a 2D Matrix
Binary Search
Find Minimum in Rotated Sorted Array
Binary Search
Two Sum II - Input Array Is Sorted
Two Pointers
Search a 2D Matrix II
Two Pointers / BS
Find the Duplicate Number
Floyd