class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        i=1
        if target>nums[-1]:
            return len(nums)
        elif target <=nums[0]:
            return 0
        elif target==nums[-1]:
            return len(nums)-1
        else:
            for m in range(1,len(nums)):
                if nums[m]<target:
                    i+=1
                else:
                    return i 


↙↙↙阅读原文可查看相关链接,并与作者交流