bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumBinary SearchLC 852

Peak Index in a Mountain Array

An array arr a mountain if the following properties hold: arr.length >= 3 There exists some i with 0 arr[i + 1] > ... > arr[arr.length - 1] Given a mountain array arr, return the index i such that arr[0] arr[i + 1] > ... > arr[arr.length - 1]. You must solve it in O(log(arr.length)) time complexity.

Asked at 7 companies
AmazonBloombergFacebook
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode