Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def peakIndexInMountainArray(self, a: List[int]) -> int:
- l,r=0,len(a)-1
- n=len(a)
- while l<r:#After converging answer will be a[l] or a[r]
- m=(l+r)>>1#compare with right one
- if a[m]<a[m+1]:#Possibility of Peak here with m+1 hence l=m+1
- l=m+1
- else:
- r=m
- return l
Advertisement
Add Comment
Please, Sign In to add comment