```
if target < nums[0]
return 0
end
if target > nums[nums.length-1]
return nums.length
end
for i in 0...nums.length do
if nums[i] == target
return i
end
if nums[i] < target && nums[i+1] > target
return i+1
end
end
end
```