The idea is simple. With the lower_bound in STL can help us find the insertion position.

```
int searchInsert(vector<int>& nums, int target) {
vector<int>::iterator iter = lower_bound(nums.begin(),nums.end(),target);
return iter - nums.begin();
}
```