1 line in C++, 3ms


  • 1
    C

    class Solution {
    public:
    int findPeakElement(vector<int>& nums) {
    return std::is_sorted_until(nums.begin(), nums.end()) - nums.begin() - 1;
    }
    };


Log in to reply
 

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