35. Search Insert Position

35. Search Insert Position

class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        self.target=target
        return self.search(nums,0)

    def search(self,nums,L):
        # print(nums,L)
        if len(nums)==0:
            return L
        mid=len(nums)//2
        if nums[mid]==self.target:
            return mid+L
        elif nums[mid]

你可能感兴趣的:(leetcode)