Skip to content

Commit cbcf260

Browse files
committed
Add binary search to find peak index in a mountain array
1 parent 5808e7c commit cbcf260

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

data_structures/arrays/peak_mountain_array.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
Description: Finds the peak index in a mountain array using binary search.
55
"""
66

7-
from typing import List
8-
9-
10-
def peak_mountain(arr: List[int]) -> int:
7+
def peak_mountain(arr):
118
start, end = 0, len(arr) - 1
129

1310
while start < end:
@@ -22,4 +19,4 @@ def peak_mountain(arr: List[int]) -> int:
2219
if __name__ == "__main__":
2320
arr = [1, 2, 3, 5, 7, 8, 6, 3, 2]
2421
peak_index = peak_mountain(arr)
25-
print(f"The peak index is: {peak_index}")
22+
print("The peak index is:", peak_index)

0 commit comments

Comments
 (0)