leetcode35. 搜索插入位置

搜索插入位置
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        
        left = 0
        right = len(nums)-1
        mid = (left+right)//2
        if targetnums[right]: return len(nums)
        while left<=right:
            if target==nums[mid]:return mid
            elif target>nums[mid] and target<=nums[mid+1]:return mid+1
            elif target

Runtime: 36 ms, faster than 98.77% of Python3 online submissions for Search Insert Position.

你可能感兴趣的:(leetcode35. 搜索插入位置)