Back to problems

Find Peak Element

Algorithm · Meta · Medium

Problem: Locate a Peak Element For an integer array nums, determine and return the index of any element that forms a peak. An element qualifies as a peak when it is larger than both adjacent values wherever those positions are present: nums[i] > nums[i-1] when i-1 is a valid index nums[i] > nums[i+1] when i+1 is a valid index Treat positions outside the array as negative infinity: nums[-1] = -∞ nums[n] = -∞ Requirements: The algorithm must have O(log n) running time. When…

Checking your access…