This is my solution with 11ms


  • -1
    W

    class Solution {
    public:
    int findPeakElement(const vector<int> &num) {
    if(num.size() <= 0)
    return -1;
    for(int i = 0; i != num.size(); i++)
    {
    if(i == num.size() -1)
    return num.size()-1;
    if(num[i] > num[i+1])
    return i;
    }

    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.