1、题目如下:
2、个人Python代码如下:
个人代码如下:
class Solution:
def search(self, nums: List[int], target: int) -> int:
left = 0
right = len(nums) - 1
while left <= right:
mid = (right + left) >> 1
if nums[mid] > target:
right = mid - 1
elif nums[mid] < target:
left = mid + 1
elif nums[mid] == target:
return mid
return -1