Find the index of a peak element in an array (an element greater than its neighbors).
Example 1
Input: nums = [1,2,3,1]
Output: 2
Explanation: The peak element 3 is at index 2.
Output: 2
Explanation: The peak element 3 is at index 2.
Example 2
Input: nums = [1,2,1,3,5,6,4]
Output: 5
Explanation: The peak element 6 is at index 5.
Output: 5
Explanation: The peak element 6 is at index 5.