Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be inserted.
Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be inserted.

Example 1:
Input: {"nums":[1,3,5,6],"target":5}
Output: 2
Input
arr ={"nums":[1,3,5,6],"target":5}

Binary search

Target: 5

LmidR1<0315263
L: 0
mid: 0
R: 3
nums[mid]: 1
Variables
VariableValue
target5
DepthFunction Call
Stack empty
0/3