← Visualizers
Binary Search — Classic LeetCode 35

Search Insert Position / visualized

Same binary search template as LC 704 — but a miss is still useful. When the range collapses, left is exactly where target would be inserted to keep the array sorted (the first index with value ≥ target).

Execution

idle
Press Run to begin.
0 / 0
Speed

Java · running line

left mid right answer / insert
O(log n) time · O(1) space  ·  on a miss, left lands on the insert index (lower_bound).