需求
代码
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
if max(nums) >=target:
for i in range(len(nums)-1):
if nums[i+1] >= target and nums[i] <target:
return i+1
if max(nums) <target:
return len(nums)
if min(nums) >= target:
return 0
if target < nums[0]:
return 0
if len(nums) ==1 and nums[0] == target:
return 0