#K48332. Find Peak Element
Find Peak Element
Find Peak Element
Given an array of integers, your task is to find any peak element and return its index. An element at index \( i \) is called a peak if it satisfies the condition
\( A[i] > A[i-1] \) (if \( i-1 \) exists) and \( A[i] > A[i+1] \) (if \( i+1 \) exists).
The array may contain multiple peaks; in such cases, returning the index of any one of the peaks is acceptable. Your solution is expected to have a logarithmic time complexity \( O(\log n) \) by using an approach similar to binary search.
Note: The array is 0-indexed.
inputFormat
The input is given via standard input. The first line contains a single integer \( n \) representing the number of elements in the array. The second line contains \( n \) space-separated integers.
outputFormat
Output via standard output a single integer representing the index of a peak element found in the array.
## sample1
1
0