class Solution:
def search(self, nums: List[int], target: int) -> int:
n=len(nums)
left,right=0,n-1
while left<=right:
k=(right-left)//2+left
if 条件:
right=k-1 #也可能是 right=k
elif 条件:
left=k+1 #也可能是 left=k
else:
return k #也可能是是return left right
return -1
标签:nums,int,二分法,leetcode,模板,left
From: https://www.cnblogs.com/suleqingfeng/p/17163562.html