A peak element is one that is strictly greater than its neighbors (elements outside the array are considered negative infinity). Given an array, return the index of any peak element. Because the standard binary search always converges to one specific peak, return that index. The array is given as an array of integers.
Input: An array of integers.
Output: Integer — the index of a peak element.
Input: [1,2,3,1]
Output: 2
Explanation: 3 at index 2 is a peak.Input: [1,2,1,3,5,6,4]
Output: 5
Explanation: Binary search converges to index 5 (value 6).Input: [1]
Output: 0
Explanation: Single element is a peak.1<=n<=1000-2^31<=value<=2^31-1adjacent values differ