A peak element is greater than its neighbors. Given an array, find a peak element's index in O(log n) time.
Input: nums=[1,2,3,1] Output: 2 (nums[2]=3 is a peak) Input: nums=[1,2,1,3,5,6,4] Output: 5
Unlock hints progressively — start gentle, go deeper only if needed.
Level 1: Gentle Nudge
A subtle direction
Level 2: Approach
The algorithm to use
Level 3: Detailed
Step-by-step guidance
to save progress and use AI features