Accepted O(n) code,


  • -4
    P
    int findPeakElement(const vector<int> &num) {
        int res = 0;
        for(int i = 0;i < num.size();++i)
        {
            if(num[i] > num[res])
            {
                res = i;
            }
        }
        return res;
    }

Log in to reply
 

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