考察知识点:数组

题目分析:

不会O(log(n))求多峰的最高峰,所以在这里就遍历一遍数组找最大值了。希望有大佬能解决这个问题捏

所用编程语言:C++

class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param heights int整型vector
     * @return int整型
     */
    int findPeakElement(vector<int>& heights) {
        // write code here
        int res = -1;
        int index = -1;
        int size = heights.size();
        for (int i = 0; i < size; i++) {
            if (heights[i] > res) {
                res = heights[i];
                index = i;
            }
        }
        return index;
    }
};