#C13845. Find Peak Element
Find Peak Element
Find Peak Element
You are given an array of integers (nums). A peak element is defined as an element that is strictly greater than its neighbors. For an element at index (i), it is a peak if it satisfies (nums[i] > nums[i-1]) and (nums[i] > nums[i+1]) (when the neighbors exist). If the array contains only one element, that element is considered a peak. Your task is to find the index of any peak element in the array. If no peak exists, output (-1).
inputFormat
The input consists of two lines. The first line contains an integer (n) representing the size of the array. The second line contains (n) space-separated integers which are the elements of the array.
outputFormat
Output a single integer representing the index of a peak element. If no peak exists, output (-1).## sample
1
1
0