Find Peak Element
题目:
There is an integer array which has the following features: The numbers in adjacent positions are different. A[0] < A[1] && A[A.length - 2] > A[A.length - 1]. We define a position P is a peek if: A[P] > A[P-1] && A[P] > A[P+1] Find a peak element in this array. Return the index of the peak.
分析:
二分让A[m-1] > A[m]和A[m] < A[m+1]时候移动,剩下情况A[m-1] <A[m] >A[m+1]就是峰值。
解法:
Last updated