0035. Search Insert Position
Binary search to find target or its insert position in a sorted array
Array:
Target:
Apply
Ex1: [1,3,5,6] t=5
Ex2: [1,3,5,6] t=2
Ex3: [1,3,5,6] t=7
Ex4: [1,3,5,6] t=0
[1] t=1
[1,3,5,7,9,11] t=8
[2,4,6,8,10,12,14] t=6
Play
Pause
Step
Reset
Speed:
1.0x
Click "Step" or "Play" to begin binary search.
Left
0
Right
3
Mid
-
Target
5
Result
-
Array Visualization
nums[
mid
] =
?
?
target =
?
Step Log