162. Find Peak Element

前面递增,后面递减,一定有波峰

二分法加快搜索的速度

class Solution {
public:
    int findPeakElement(vector<int>& nums) {
        int start = 0;
        int end = nums.size() - 1;
        int mid;
        while(start + 1 < end){
            mid = start + (end - start)/2;
            if(nums[mid] < nums[mid + 1])
                start = mid;
            else
                end = mid;
        }
        return nums[start] > nums[end] ? start : end;
    }
};