mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-18 03:49:22 -04:00
Update bs_rotated_array.py
This commit is contained in:
parent
5456593be9
commit
d0bbfed0e5
1 changed files with 2 additions and 2 deletions
|
@ -21,7 +21,7 @@ def search(nums):
|
||||||
# 2. write a binary search
|
# 2. write a binary search
|
||||||
def bs(left, right, target):
|
def bs(left, right, target):
|
||||||
|
|
||||||
while left < right:
|
while left <= right:
|
||||||
|
|
||||||
mid = (left + right) // 2
|
mid = (left + right) // 2
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ def search(nums):
|
||||||
return mid
|
return mid
|
||||||
|
|
||||||
elif nums[mid] > target:
|
elif nums[mid] > target:
|
||||||
right = mid
|
right = mid - 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
left = mid + 1
|
left = mid + 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue