```
int searchhelp(vector<int>& nums, int target, int l, int r) {
if (l==r) return l;
int m = l+(r-l)/2;
if (target <= nums[m]) return searchhelp(nums, target, l, m);
else return searchhelp(nums, target, m+1, r);
}
int searchInsert(vector<int>& nums, int target) {
return searchhelp(nums, target, 0, nums.size());
}
```