Skip to content

Commit 94d52ee

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent dacde35 commit 94d52ee

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

searches/meta_binary_search.py

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
def meta_binary_search(arr, target):
2-
low = 0
3-
high = len(arr) - 1
4-
while low <= high:
5-
mid = (low + high) // 2
6-
if arr[mid] == target:
7-
return mid
8-
elif arr[mid] < target:
9-
low = mid + 1
10-
else:
11-
high = mid - 1
12-
return -1
2+
low = 0
3+
high = len(arr) - 1
4+
while low <= high:
5+
mid = (low + high) // 2
6+
if arr[mid] == target:
7+
return mid
8+
elif arr[mid] < target:
9+
low = mid + 1
10+
else:
11+
high = mid - 1
12+
return -1
13+
1314

1415
def main():
15-
arr = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]
16-
target = 23
17-
result = meta_binary_search(arr, target)
18-
if result != -1:
19-
print("Element found at index: ", result)
20-
else:
21-
print("Element not found!")
16+
arr = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]
17+
target = 23
18+
result = meta_binary_search(arr, target)
19+
if result != -1:
20+
print("Element found at index: ", result)
21+
else:
22+
print("Element not found!")
23+
2224

2325
if __name__ == "main":
24-
main()
26+
main()

0 commit comments

Comments
 (0)