###### 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; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up