#K61577. Peak Element Finder
Peak Element Finder
Peak Element Finder
You are given an array of integers. Your task is to find any index of a peak element in the array. An element is called a peak if it is not smaller than its neighbors. More formally, for an index i, the element arr[i] is a peak if:
\(arr[i] \ge arr[i-1]\) (if \(i > 0\)) and \(arr[i] \ge arr[i+1]\) (if \(i < n-1\)).
Note that if the array contains only one element, that element is considered a peak. It is guaranteed that at least one peak element exists. In case there are multiple peaks, you can output the index of any one of them.
inputFormat
The input is read from standard input (stdin). The first line contains a single integer n (1 ≤ n ≤ 105) denoting the number of elements in the array. The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output a single integer to standard output (stdout) which is the index of any peak element in the array.## sample
1
10
0
</p>