Peak Index in a Mountain Array

You are given a mountain array where the values increase to a peak element and then decrease. Your task is to return the index of the peak element in O(log(n)) time complexity.

Constraints

  • 3 <= arr.length <= 10^5
  • 0 <= arr[i] <= 10^6
  • arr is guaranteed to be a mountain array.
Saving… · 2 lines
class Solution:
def peakIndexInMountainArray(self, arr) -> int:
Console

Click Run to execute sample tests.