Skip to content

Commit 6dc371f

Browse files
authored
Update peak-index-in-a-mountain-array.py
1 parent bbf9792 commit 6dc371f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/peak-index-in-a-mountain-array.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# Space: O(1)
33

44
class Solution(object):
5-
def peakIndexInMountainArray(self, A):
5+
def peakIndexInMountainArray(self, arr):
66
"""
7-
:type A: List[int]
7+
:type arr: List[int]
88
:rtype: int
99
"""
10-
left, right = 0, len(A)
11-
while left < right:
10+
left, right = 0, len(arr)-1
11+
while left <= right:
1212
mid = left + (right-left)//2
13-
if A[mid] > A[mid+1]:
14-
right = mid
13+
if arr[mid] > arr[mid+1]:
14+
right = mid-1
1515
else:
1616
left = mid+1
1717
return left

0 commit comments

Comments
 (0)