class Solution(object):
# def peakIndexInMountainArray(self, A):
# """
# :type A: List[int]
# :rtype: int
# """
# i = 0
# while A[i + 1] >= A[i]:
# i += 1
# return i
def peakIndexInMountainArray(self, A):
lo, hi = 0, len(A) - 1
while lo < hi:
mid = (lo + hi) / 2
if A[mid] < A[mid + 1]:
lo = mid + 1
else:
hi = mid
return lo
Download Peak Index in a Mountain Array.pyLeetcode 852 Peak Index in a Mountain Array problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.