Find Peak Element
Medium

Problem Statement

A peak element is an element that is strictly greater than its neighbors. Given an integer array `nums`, find a peak element and return its index. The array may contain multiple peaks; in that case, return the index to any of the peaks. You may imagine that `nums[-1] = nums[n] = -∞`.

Examples

1Example 1
Input:
{ "nums": [ 1, 2, 3, 1 ] }
Output:
2
2Example 2
Input:
{ "nums": [ 1, 2, 1, 3, 5, 6, 4 ] }
Output:
5
3Example 3
Input:
{ "nums": [ 1 ] }
Output:
0
Loading...

Sign in to Run Code and Submit