Search⌘ K
AI Features

Solution: Peak Index in a Mountain Array

C# solution for the Peak Index in a Mountain Array problem using the Modified Binary Search pattern.

Statement

Given an integer array arr that is guaranteed to be a mountain array, return the index of its peak element. The peak is the element that is strictly greater than its adjacent elements, where values strictly increase up to the peak and then strictly decrease after it.

Note: A mountain array has some index i such that arr[0] < arr[1] < ... < arr[i] and arr[i] > arr[i+1] > ... > arr[arr.length - 1].

Constraints:

  • 33 \leq ...