public int findPeakElement(int[] nums) {
        int begin = 0, end = nums.length - 1;
        while (begin + 1 < end) {
            int mid = begin + (end - begin) / 2;
            if (nums[mid] < nums[mid + 1]) {
                begin = mid;
            } else if (nums[mid] < nums[mid - 1])
                end = mid;
            else begin = mid;
        }
        if (nums[begin] < nums[end])
            return end;
        else
            return begin;
    }