Find Peak Element
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a **mountain-shaped** integer array nums: its values strictly increase up to a single highest element and then strictly decrease. Either side may be empty, so a strictly increasing or strictly decreasing array also counts. That highest element is the array's only **peak**, meaning it is strictly greater than each neighbour that exists.
Return the index of the peak.
Your solution must run in O(log n) time.
Examples
Constraints
- 1 <= nums.length <= 1000
- -2^31 <= nums[i] <= 2^31 - 1
- `nums` strictly increases and then strictly decreases (either part may be empty), so exactly one peak exists.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.