LeetCode-35-Search Insert Position 裸lower_bound

来源:互联网 发布:高功能自闭症 知乎 编辑:程序博客网 时间:2024/06/15 18:28


class Solution(object):    def searchInsert(self, nums, target):        """        :type nums: List[int]        :type target: int        :rtype: int        """        Len=len(nums)        if Len==0:return 0        l=0        r=Len        while l<r:            m=(l+r)/2            if nums[m]<target:                l=m+1            else:                r=m        return r


原创粉丝点击