#K13996. Find Peak Element
Find Peak Element
Find Peak Element
You are given an array of integers. A peak element is defined as an element that is strictly greater than its neighbors. For elements on the edges of the array, only one neighbor is considered. Your task is to find the index of the first peak element in the array. If multiple peak elements exist, return the index of the first one encountered. If no peak element exists, return \(-1\).
Note: The array may be empty, in which case you should output \(-1\). For an array with a single element, it is considered a peak by default.
Example:
- For the input array: [1, 3, 2], the peak element is 3 at index 1, so the output is 1.
inputFormat
The first line of input contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers, which are the elements of the array.
outputFormat
Output a single integer: the index of the first peak element in the array. If no peak element exists, output \(-1\).
## sample1
1
0