← All problems
Find First and Last Position in Sorted Array
Find the start/end indices of target in sorted array; [-1,-1] if absent.
Complexity
Time O(log n), Space O(1)
Common pitfalls
- Linear expansion after find (O(n) worst)
- Off-by-one in bound variants
Your solution
Log in to save your code and track progress.