0034. Find First and Last Position of Element in Sorted Array
Two Binary Searches: Left Bound + Right Bound | O(log n) Time
Array:
Target:
Load
Example 1: [5,7,7,8,8,10] t=8
Not Found: [5,7,7,8,8,10] t=6
All Same: [8,8,8,8,8] t=8
Single: [1] t=1
Long Run: [1,2,2,2,2,2,3] t=2
At Edges: [3,3,5,5,7,7] t=7
Ready — Press Step or Play to begin
Search Phase
—
Not started
Pointers
lo=? hi=? mid=?
—
Result (so far)
[-1, -1]
No occurrence found yet
Step
0
Total binary search steps
Step
Play
Pause
Reset
Speed:
5x
Step Log