35. Search Insert Position

class Solution(object):
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        return self.binarySearch(nums,0,len(nums)-1,target)
    def binarySearch(self,nums,left,right,target):
        if left>right : return left
        if left==right: 
            if nums[left]target: return self.binarySearch(nums,left,mid,target)
        else: return self.binarySearch(nums,mid+1,right,target)

你可能感兴趣的:(35. Search Insert Position)