Find peak element

Write codeMedium18 minGoogle and Meta style

Your task

A peak element is one strictly greater than its neighbors; out-of-bounds neighbors are treated as negative infinity. Given an integer array nums where no two adjacent elements are equal, return the index of any peak element in O(log n) time. Array length up to 1e5.

Examples

find_peak_element(nums: list[int]) -> int
Example 1
Inputfind_peak_element([1, 2, 3, 1])
Output2