Skip to content

Commit

Permalink
Update 0704.二分查找.md
Browse files Browse the repository at this point in the history
  • Loading branch information
changcv2021 committed Sep 22, 2022
1 parent 2253781 commit 4eaca5f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions problems/0704.二分查找.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ class Solution:
def search(self, nums: List[int], target: int) -> int:
if nums is None or len(nums)==0:
return -1
l,r=0,len(nums)
while (l<r):
m = round(l+(r-l)//2)
if nums[m] == target:
return m
elif nums[m] > target:
r=m
left,right=0,len(nums)
while (left<right):
middle = round(left+(right-left)//2)
if nums[middle] == target:
return middle
elif nums[middle] > target:
right=middle
else:
l=m+1
left=middle+1
return -1
```

Expand Down

0 comments on commit 4eaca5f

Please sign in to comment.