Skip to content

Commit 8d36b9a

Browse files
committed
Fixed binary search
1 parent 7606bc7 commit 8d36b9a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

search_in_rotated_sorted_array/solution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def search(self, A, target):
1212
# Left part is sorted
1313
if A[mid] > A[right]:
1414
if target < A[mid] and target >= A[left]:
15-
right -= 1
15+
right = mid - 1
1616
else:
17-
left += 1
17+
left = mid + 1
1818
# Right part is sorted
1919
else:
2020
if target > A[mid] and target <= A[right]:
21-
left += 1
21+
left = mid + 1
2222
else:
23-
right -= 1
23+
right = mid - 1
2424
return -1

0 commit comments

Comments
 (0)