class Solution: def search(self, nums: List[int], target: int) -> int: left, right = 0, len(nums)-1 while right >= left: result = (right - left) // 2 + left if target == nums[result] : return result elif target > nums[result]: left = result + 1 else : right = result - 1 return - 1
评论