def search(self , nums: List[int], target: int) -> int:
# write code here
l = 0
r = len(nums) - 1
# 從陣列首尾開始,直到二者相遇
while l <= r :
# 每次檢查中點的值
m = int((l+r)/2)
if nums[m] == target:
return m
# 進入左的區間
if nums[m] > target:
r = m - 1
# 進入右區間
else:
l = m + 1
# 未找到
return -1