```
class Solution {
func searchInsert(_ nums: [Int], _ target: Int) -> Int {
var answer = 0
for i in 0 ..< nums.count{
if target <= nums[0]{
answer = 0
}else if target <= nums[i] && target > nums[i-1]{
answer = i
}else if target > nums[i]{
answer = i + 1
}
}
print(answer)
return answer
}
}
```