Hardware interview practice
Find lower and upper bounds
For a sorted integer array, return the first index with value >= target and the first index with value > target.
Reviewed example
Work through one case
Input
values = [1, 2, 2, 2, 5], target = 2Expected output
lower_bound = 1, upper_bound = 4The half-open matching range [1,4) contains all three occurrences of 2.
What to cover
Requirements
- Return values.size() when the requested bound does not exist.
- Handle duplicate targets correctly.
- Use half-open search intervals.
