Find First and Last PositionMedium

array binary search

Given a sorted array, return the first and last index of target in O(log n). Two approaches — watch how a linear scan compares to two boundary binary searches.

Press play to watch the algorithm run.
Metrics
Legend
How it works
0 / 0