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
leftmidrightanswer / insert
O(log n) time · O(1) space · on a miss, left lands on the insert index (lower_bound).