35.Search Insert Position

 

 

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

 

posted @ 2020-05-09 15:19  星海寻梦233  阅读(106)  评论(0编辑  收藏  举报