Search Insert PositionEasy

array binary search

Given a sorted array of distinct integers and a target, return its index if found — otherwise the index where it would be inserted to keep the array sorted. Required runtime: O(log n).

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