A peak element in a 0-indexed integer array is one that is strictly greater than its neighbors. The task is to find such a peak element and return its index. If multiple peaks exist, any of them can be returned. The array is considered to have virtual elements with negative infinity at its two ends for comparison purposes. The solution must be optimized to run in logarithmic time complexity, O(log n).
Click Run to execute sample tests.