> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/binary-search/852.-peak-index-in-a-mountain-array.md).

# 852. Peak Index in a Mountain Array

![](/files/-MivTjRv2l-0UoSeE74s)

![](/files/-MivTmyfh3Uhjfn5P2vX)

![](/files/-MivTrfWyl2pQb8-F6yl)

time: O(logn)

space: O(1)

```java
class Solution {
    public int peakIndexInMountainArray(int[] arr) {
        int start = 0;
        int end = arr.length - 1;
        
        while (start + 1 < end) {
            int mid = start + (end - start)/2;
            if (arr[mid] < arr[mid+1]) {
                start = mid;
            } else {
                end = mid;
            }
        }
        return Math.max(start, end);
    }
}
```
