1 class Solution: 2 def searchInsert(self, nums: List[int], target: int) -> int: 3 left, right = 0, len(nums)-1 4 5 while left <= right: #左闭右闭 6 mid = left + (right-left) // 2 7 if nums[mid] < target: 8 left = mid + 1 9 elif nums[mid] > target: 10 right = mid - 1 11 else: 12 return mid 13 14 return right + 1标签:right,int,35,34,查找,数组 From: https://www.cnblogs.com/wuyijia/p/17663226.html