###### tags: `LeetCode` `Binary Search` `Easy` # LeetCode #852 [Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array/) ### (Medium) 與[#162](https://hackmd.io/Pymu5cNRRziTRYo0GxeNoA)一樣 ``` class Solution { public: int peakIndexInMountainArray(vector<int>& arr) { int l=0, r=arr.size()-1; while(l<r){ int m=l+(r-l+1)/2; if(arr[m]<=(m-1>=0?arr[m-1]:INT_MIN))r=m-1; else l=m; } return l; } }; ```