Search for a Range

Given a sorted array of integers, find the starting and ending position of a given target value.

Your algorithm’s runtime complexity must be in the order of O(log n).

If the target is not found in the array, return [-1, -1].


Given [5, 7, 7, 8, 8, 10]

and target value 8,

return [3, 4].

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Search for a Range on Interview Code Editor
Sign Up
to access hints and editorial solutions for Search for a Range
Asked In:


Click here to start solving coding interview questions