Search Insert Position
easyGiven a sorted array and a target, return the index if found or where it would be inserted to keep sorted order
Search Insert Position
Key Insight
When target is not found, left pointer lands exactly at the insertion point.
Step 1Initialize
Target: 2
L
R
1
03
15
26
3Search space: [0..3]
left=0, right=3. Searching for 2.
1 / 5