A peak element is an element that is strictly greater than its neighbors.
Given a -indexed integer array , find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that a_{-1} = a_n = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array.
The first line contains the size of array n~(n \le 10^6). The second line contains integers a_0, a_1, \ldots, a_{n-1}. It is known that |a_i| \le 10^9 and also that a_i \ne a_{i + 1} for i = 0, 1, \ldots, n - 2.
Print the index of a peak element. If the array contains multiple peaks, return the index to any of the peaks.
Example 1
Example 2