Search⌘ K
AI Features

Problem: Find Peak Element

Explore how to locate a peak element in an integer array efficiently using a binary search algorithm. Understand the approach that leverages array boundaries and element comparisons to achieve logarithmic time complexity while handling edge and boundary conditions.

Statement

A peak element in an array is one that is strictly greater than both of its neighbors.

Given a 00-indexed integer array nums, return the index of any peak element.

Note: Elements at the boundaries of the array are compared against -\infty. That is, nums[-1] and nums[n] are both treated as -\infty, where n is the length of nums ...