Question bank › Binary Search
Dsa Binary Search Medium

Find Peak Element in Unimodal Array

You are given a unimodal array (an array that increases and then decreases). You need to find a peak element in this array, which satisfies the condition that the element is greater than or equal to its neighbors. If the array is [1, 3, 5, 4, 2], the peak is 5 at index 2. If there are multiple peaks, return the index of any peak. Input Format: - The first line contains an integer n (1 ≤ n ≤ 1000), the number of elements in the array. - The second line contains n space-separated integers representing the array elements. Output Format: - A single integer representing the index of one peak element. Example: Input: 5 1 3 5 4 2 Output: 2

Key concepts

binary_searcharraysearching

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.